Search Unity

How to stop a navAgent dead on its track?

Discussion in 'Navigation' started by laurentlavigne, Mar 12, 2018.

  1. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364
    If I don't want any slow down and the agent stops immediately how do I do that?
    I've tried the old Stop(), isStopped=true, auto brake on and off, all have some latency.
     
  2. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364
    Solution: set acceleration to 1000 and braking will be instant.
     
  3. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,982
    That doesnt seem like a full solution? Is there a way to get braking to apply without affecting acceleration?
     
  4. SM_AF

    SM_AF

    Joined:
    Aug 1, 2017
    Posts:
    23
    How about:
    Code (CSharp):
    1. navMeshAgent.isStopped = true;
    2. navMeshAgent.velocity = Vector3.zero;
     
    zastroph and laurentlavigne like this.
  5. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    6,364
    It works, thanks for this better solution.