- Home /
Move NavMeshAgent at a constant speed
My NavMeshAgent randomly changes speed while moving along it's path. It seems to be slower when a segment of a path is shorter (between two waypoints/corners) or when there are many close continuous corners ahead. I have tried changing the acceleration and angular speed but that didn't work. I have also tried changing the agent.velocity and even though I set it to vectors of the same magnitude each frame, it still doesn't move at a constant speed. I have also checked if everything is on the same Y coordinates since my game is top down orthographic.
Answer by mxoconnell · Nov 15, 2019 at 03:14 PM
From here, https://docs.unity3d.com/ScriptReference/AI.NavMeshAgent.html Maybe read the desired velocity and if its higher than you want, set the velocity to be of the desired magnitude
if(desiredVel > kSpeed)
vel = kSpeed * normalize(vel)