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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

NavMesh Components - can two agent types pass through each other?

Discussion in 'Navigation' started by Szymanik, Mar 19, 2020.

  1. Szymanik

    Szymanik

    Joined:
    May 6, 2018
    Posts:
    1
    Hello! So, i have two NavMesh Surfaces, one that handles Humanoid agent type, and the other one, baked without walls etc that handles Ghost agent type (so he can move through walls and such). Now i need to make those two agent types pass through each other. I can't figure out how to do it.

    What I've already tried:
    - setting stuff on different layers and disabling collision between any layers in ps > physics, also just in case in ps > pshysics 2d.
    - setting Ghost agent's obstacle avoidance to none, makes Ghost push Humanoids instead of going through
    - internet suggests setting agents' radius to a very small number - can't do that since the Humanoid type agent needs a normal radius so he can avoid obstacles as usual

    Any help would be very appreciated! (maybe i should do things entirely differently?)
     
    Roger-W likes this.
  2. vhman

    vhman

    Joined:
    Aug 13, 2018
    Posts:
    333
    Hi,

    Put ghost Agent NavMeshAgent.baseOffset to 1000 and NevMEshSurface z=1000, so ghost will fly over.
    The better solution is to implement new Agent
     
    Roger-W likes this.
  3. Roger-W

    Roger-W

    Joined:
    Oct 28, 2018
    Posts:
    5
    How would you implement a new agent?
     
  4. vhman

    vhman

    Joined:
    Aug 13, 2018
    Posts:
    333
    Hi @RogerW2520

    On a large scale path finding consist of global and local pathing. Good news is that NavMesh has all we need for Global pathing https://docs.unity3d.com/ScriptReference/AI.NavMesh.CalculatePath.html. While NavMeshAgent implement local pathing (dynamic pathing or obstacle avoidance, call it as you want) it does not expose public API very well. Also inner structure for agent is unknown.

    So what we need is two features, following the path, and obstacle avoidance.
    First one is trivial, https://www.habrador.com/tutorials/math/2-passed-waypoint/
    Second part is tricky, but also can be solved in simple way with physics ray-casts
    https://www.gamasutra.com/view/feature/131724/smart_move_intelligent_.php?page=2

    Al depends on purpose, skills and time.
     
    Roger-W likes this.