Question by
Eiseno · Apr 26, 2016 at 08:12 AM ·
velocitynavmeshnavmeshagent
What does desiredVelocity do?
Hi, What does desiredVelocity do? What's diffrence between velocity ? And why should i use it ?
Example Code:
void NavAnimationUpdate()
{
speed = Vector3.Project(agent.desiredVelocity, transform.forward).magnitude;
// angle is the angle between forward and the desired velocity.
angle = FindAngle(transform.forward, agent.desiredVelocity, transform.up);
// If the angle is within the deadZone
// set the direction to be along the desired direction and set the angle to be zero.
if (Mathf.Abs(angle) < deadZone)
{
transform.LookAt(transform.position + agent.desiredVelocity);
angle = 0f;
}
animSetup.Setup(speed, angle);
}
Comment
Your answer
Follow this Question
Related Questions
Navigatin Mesh agent works for ~10 seconds, then starts moving sporadically 0 Answers
Creating NavMeshAgent types at runtime 0 Answers
AI Car Lane follow 0 Answers
problems with nav mesh agent 0 Answers