Search Unity

  1. Check out our Unite Austin 2017 YouTube playlist to catch up on what you missed. More videos coming soon.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  6. Unity 2017.3 beta is now available for download.
    Dismiss Notice

NavMeshAgent autoBraking/stoppingDistance Internals

Discussion in 'Navigation' started by Multithreaded_Games, Oct 12, 2017.

  1. Multithreaded_Games


    Jul 6, 2015
    Hi all,

    I am attempting to replicate the behavior of the NavMeshAgent's autobraking 'adjustments' as it pertains to altering the velocity of the NavAgent as it approaches its target. My assumption is that the entity is moving in a straight line (no obstacles to avoid or directional changes.) Essentially, I need to stop the target as close to the destination as possible and am able to achieve this with a mixture of parameters (high acceleration, small stopping distance) However, for other reasons, I need to update the navmesh position myself, thus I am setting updatePosition to false and the velocity to zero. Once the velocity is set to zero, it seems that the autoBraking behavior disables entirely. Since the autoBraking behavior works quite well, I'm curious as to how it's implemented under the hood.

    Key questions I have:

    1.) When does the autoBraking actually kick in? In other words, at what distance/time from the target position does the NavAgent say, "OK, start to decrease my speed"? From what I can tell, it doesn't start once remainingDistance < stoppingDistance, but the velocity starts to decrease usually way before then.

    2.) What is the actual formula for determining the new velocity vector based on the acceleration? Is it actually physics-based or is it something else? Actual code/pseudocode would be amazing (if one of the devs could chime in, that'd be great!)

    I'm hoping that there is someone out there who knows or has managed to figure out how this works exactly. Thanks!