Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

NPC roam visability

Discussion in 'General Discussion' started by Nuse, Apr 26, 2022.

  1. Nuse

    Nuse

    Joined:
    Jun 24, 2015
    Posts:
    5
    I am new to Unity and if this is not the best location to post this, please give me direction and I will put this where it goes.

    I am tasked with creating monsters for a game in my teams class project, I am trying to figure out how to make tool for classmate. The monsters have a range on the x and z axis they will roam away from tier spawn location. I want to make a tool that will resize in the scene view as the monsters roam distance is adjusted by the team member who is responsible for level design and will be placing the monsters. The tool will be set to inactive when the game starts.

    Where I am at now, I have a cube primitive whose location is set to the monsters location and a child of this monster. Its alpha is turned up so that it is transparent and the floor is visible through and is scaled up to roughly the default monster roaming area. I want to give my team mate a variable to set the roam distance and this transparent cube adjusts to let them see the roaming distance visually while setting up monsters in the game level.

    Is this possible?

    upload_2022-4-26_6-59-16.png
     
  2. DragonCoder

    DragonCoder

    Joined:
    Jul 3, 2015
    Posts:
    1,492
    Is it rectangular on purpose or would you rather have a sphere/circle?
    For developer information like that, the so called Gizmos are often used. If the methods are placed in the corresponding event (https://docs.unity3d.com/ScriptReference/MonoBehaviour.OnDrawGizmosSelected.html ) you can draw colored spheres, wire frame shapes and a couple other things.

    Alternatively your concept works too. Just scale the transform.localScale of that visualizer child cube. Or where exactly are you stuck?
     
    Last edited: Apr 26, 2022
  3. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,380
    I'm sure it is, but rather than having a game object that represents your range, you could simply draw a cube using Gizmos.DrawCube in the OnDrawGizmos monobehaviour method in your enemy GameObject. Gizmos are only rendered in sceneview and they are provided to do the exact thing that you're trying to do.
     
  4. Nuse

    Nuse

    Joined:
    Jun 24, 2015
    Posts:
    5

    Thanks,
    That is exactly what I was looking for, Gizmos. I've only been doing this for about two weeks and didn't have the correct vocabulary to look this up properly, and it seemed like something I should be able to do.
     
  5. Nuse

    Nuse

    Joined:
    Jun 24, 2015
    Posts:
    5
    Thanks,
    I'll look up Gizmos.DrawCube. The rooms in our dungeon are rectangular this will be perfect.