I’m using a quick Quaternion.Lerp to turn a human character around before he starts running in that direction. Here’s how I setup the Lerp ( this is within an Update() ):
if(rotating)
{
Vector3 pos = nav.destination - transform.position;
Quaternion newRot = Quaternion.LookRotation(pos);
Debug.Log("tranform: "+ transform.rotation + " newRotation: " + newRot);
if(transform.rotation == newRot)
Debug.Log("FACING THE RIGHT DIRECTION !!!!!!!!!!!!!!!!!!!!!");
if(transform.rotation != newRot)
transform.rotation = Quaternion.Lerp(transform.rotation, newRot, .0005f);
else
{
rotating = false;
if(nav.remainingDistance > nav.stoppingDistance)
{
moving = true;
}
}
}
The debug that states when the transform is facing in the right direction never hits yet from the other debug I can see that transform.rotation will be equal to newRot variable. Is there a better way to check when the object is facing the correct direction? Thanks in advance.