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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

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:
    5,987
    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:
    5,987
    Solution: set acceleration to 1000 and braking will be instant.
     
  3. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,874
    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:
    5,987
    It works, thanks for this better solution.