- Home /
Increase NavMesh Rotation Speed
1.)I am utilizing an animation controller and navmesh agent. The Animation controller simply plays a walking forward animation and the navmesh agent controls the rotation of the agent.
I have tried changing the angular speed of the agent and nothing has changed.
I am looking for a way to make my agent's rotation speed faster so they can navigate around corners quicker. The angular speed did nothing when I changed it.
2.)On a side note I have used two different kinds of animations, one which displaces the animator and one which animates them without any changing their placement in any way.
Is there a way to stop an animation from changing the velocity of my actor?
Answer by Carnivorous · Mar 01, 2017 at 02:56 PM
This solved the problem for me. Call the extraRotationSpeed once in every Update().
float extraRotationSpeed;
void extraRotation()
{
Vector3 lookrotation = agent.steeringTarget-transform.position;
transform.rotation = Quaternion.Slerp(transform.rotation,Quaternion.LookRotation(lookrotation), extraRotationSpeed*Time.deltaTime);
}
void Update()
{
extraRotation();
}
when the agent reaches the target it turns to face to the players starting rotation, how can i fix
Answer by brunopava · Jul 10, 2014 at 01:16 PM
Hi, I had the same problem once. But looking at the API reference I discovered that angularSpeed receives influence from both speed and acceleration. So I played around and found that if you increase acceleration you can reach the desired rotation speed that you want.
My current configuration is:
Speed 7
Acceleration 10
Angular Speed 999 (dunno if a high number is valid here, but hey it works)
Answer by lex24 · Aug 19, 2014 at 11:48 AM
1) NavMeshAgent actual turn speed is faster if its velocity is small. In my project I'm simulating car traffic in a city and I need my car to turn faster on road crossings.
To solve this problem I'm using this:
void changeSpeed()
{
float speedMultiplyer = 1.0f - 0.9f*Vector3.Angle(transform.forward, agent.steeringTarget-transform.position)/180.0f;
agent.speed = moveSpeed*speedMultiplyer;
}
void Update()
{
changeSpeed();
}
void Start () {
agent = gameObject.GetComponent("NavMeshAgent") as NavMeshAgent;
}
For this to work correctly agent.acceleration value must be near or greater than agent.speed value
2) remove "Apply Root Motion" checkmark from Animator component of your actor, or set Animator.applyRootMotion to FALSE when needed by script if you need to disable root motion only for some animations.