I recently tested the Navmesh feature if Unity 3.5, right now I have character with a rigid body and one without, both have Navmesh agents and I’ve tested them both, but when at high speeds they tend to slide past the target and never reach the stopping distance. The rigid body is not causing this so, how can i stop this sliding?
Try setting the acceleration to be a high number such as 60. Note that navMeshAgent stop its force at that location but will still move forward due to inertia. A high acceleration will make it stop very close to that exact location
turn auto braking off
I’m seeing that this is STILL an issue in Unity 5. For anyone who is still experiencing this issue, here is a solution that works for me:
public float acceleration = 2f;
public float deceleration = 60f;
public float closeEnoughMeters = 4f;
private NavMeshAgent navMeshAgent;
void Start()
{
navMeshAgent = gameObject.GetComponentInChildren<NavMeshAgent>();
}
void Update()
{
if (navMeshAgent)
{
// speed up slowly, but stop quickly
if (navMeshAgent.hasPath)
navMeshAgent.acceleration = (navMeshAgent.remainingDistance < closeEnoughMeters) ? deceleration : acceleration;
}
}
Hello from the year 2021. I solved the issue by increasing the acceleration. The agent slows when going into corners, so it needs to speed up rapidly coming out of corners to stay on the path. Version 2020.3 LTS.
I found a better answer. Just do Agent.velocity = Agent.desiredVelocity; in Update
in my case, setting acceleration to 60 does not work.
so i have to create another solution like this.
if (Vector3.Distance(target, transform.position) < navMeshAgent.stoppingDistance)
{
navMeshAgent.SetDestination(transform.position);
}
else
{
navMeshAgent.SetDestination(target);
}
I got the Same Issue but my character was slipping while turning.
This works for me.
Increase “Acceleration” and increase “Angular Speed”.
Values for my Character
Speed=30
Angular Speed=300
Acceleration=140