Search Unity

Temporarily turning off NMA to apply my own direct movement and the speed is WAY off.

Discussion in 'Navigation' started by Not_Sure, Aug 22, 2018.

  1. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    3,546
    I'm programming an enemy AI that uses a NavMeshAgent and I want it to periodically dart to a random direction.

    Since NMA doesn't do sudden shifts very well I decided it would be easiest to simply turn it off, do the movement, then turn it back on.

    It all works really well, but for whatever reason the movement speed does NOT match up with the speed set in the NavMeshAgent and is much (MUCH) faster.

    for example:
    Code (CSharp):
    1. transform.Translate(Vector3.forward * Time.deltaTime * myNMA.speed );
    (myNMA is the NavMeshAgent).
    Telling it to move like this seems to have it going ~25% faster than it moves through NavMeshAgent.

    EDIT: Actually, I do know why it's sluggish in NMA. It's having to re-accelerate every time it turns back on. Any way I can directly tell it to go full speed when it turns back on?
     
  2. chainsawpenguin

    chainsawpenguin

    Joined:
    Sep 28, 2014
    Posts:
    107
    You can set the acceleration value very high on the NMA through your script, so that it's basically instantly at full speed.