Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Agent too close too the edge of NavMesh

Discussion in 'Navigation' started by HeyBishop, May 15, 2018.

  1. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    111
    I've got an agent wandering around my scene to random points on the NavMesh. Unfortunately, sometimes it gets too close to and edge, and then it will slip and fall.

    I've tried making my agent radius bigger, smaller. I've put it on an child object and moved toward the front, to the centre. I've adjusted the NavMesh Max Slope and Step Height. Yet, this wolf always seems to fall eventually.

    Any suggestions on how I can prevent this from happening?

    In the video below, I demonstrate the problem I'm facing.



    (I've cross-posted here)
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    2,089
    How are you actually moving the agent? Is there a rigidbody on the agent, and the momentum is just carrying the agent forward off the edge? Are you moving with root motion applied to an animation, such that the animation is forcing the agent forward?
     
  3. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    111
    Hmmm ... I'm still kinda new to Unity and coding. The creator of the animal assets I'm using could probably answer this better than me, that would be @Malbers.

    There is a rigidbody on the gameObject, but Root Motion is also applied. Or, as it is stated on the Animator, root motion is "Handled by Script".

    upload_2018-5-16_14-19-21.png
     
  4. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    1,594
    For the animals I raycast a Fall ray in front of them... so they can predict if there's a posible cliff...

    you can fix this by changing the Front Fall Ray multiplier to 0 on the animal script..

    upload_2018-5-16_13-36-24.png

    This should solve it...

    but for reassuring purposes you can always put an invisible wall ) to avoid the animal falling from a cliff
     
  5. Malbers

    Malbers

    Joined:
    Aug 7, 2015
    Posts:
    1,594
    Also you can increase the Turn Multiplier To a higher value than 100 so the animal can turn faster and avoid going forward while turning on a 180 degree angle...
     
  6. HeyBishop

    HeyBishop

    Joined:
    Jun 22, 2017
    Posts:
    111
    Oh my gosh! How could I have missed this!!?
    I'm testing these animals now, so far, so good. There is still the occasional fall - but I'm actually okay with that, because it is true to life. I'll have to figure out a way to script a death if they fall too far.
     
    Malbers likes this.