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

Navmesh Agent constant speed?

Discussion in 'Navigation' started by jessee03, Mar 6, 2020.

  1. jessee03

    jessee03

    Joined:
    Apr 27, 2011
    Posts:
    729
    Is there a way to get a navmesh agent to remain at a constant speed? I'm trying to create a NPC that follows the player and want the agent to run as fast as the player when close to the player. Problem is I keep getting a rubber band effect where the enemy slows down and speeds up when following the player. Also I have auto breaking turned off.
     
  2. DwinTeimlon

    DwinTeimlon

    Joined:
    Feb 25, 2016
    Posts:
    296
    Have you tried fiddling with the
    NavAgent.acceleration
    parameter?
     
    Tribubb likes this.
  3. Terraya

    Terraya

    Joined:
    Mar 8, 2018
    Posts:
    646
    same problem here,

    @jessee03 have you found any solution?

    @DwinTeimlon im going to try it now, gonna update if i figure it out
     
  4. Terraya

    Terraya

    Joined:
    Mar 8, 2018
    Posts:
    646
    Ok actualy the fix easy, just very dumb of me that i didnt notice it ...

    the NavMeshAgent Component has a boolean "Auto Braking", just set it to false , and its fixed x)
     
    tfalves likes this.
  5. jessee03

    jessee03

    Joined:
    Apr 27, 2011
    Posts:
    729
    I still haven't got mine to work properly. I'm trying to make it so acceleration is disabled and the navmesh agent moves at it's set "speed" variable at all times. Not sure how to get around this
     
    Tribubb likes this.
  6. Terraya

    Terraya

    Joined:
    Mar 8, 2018
    Posts:
    646
    to get that done you need to set its speed straight to the speed you want if you don't want "any" acceleration, or maybe try to set the acceleration to a very very high amount, so it will look like there is none
     
    Tribubb, jtachikawa and doudar like this.
  7. doudar

    doudar

    Joined:
    Mar 25, 2020
    Posts:
    2
    I've made acceleration 100 and speed 2 and it seems ok.
     
    veronicaSmiles and Tribubb like this.
  8. New_Game_Ideas

    New_Game_Ideas

    Joined:
    Jul 17, 2021
    Posts:
    4
    Thanks, Terraya. I had to work a little bit but it is working almost perfectly.
     
    Terraya likes this.