hoe to rotate a AI as a animation

hello,

I have a waypoint system if the player reaches the waypoint he wil rotate to the next now i use
transform.LookAt

The negative thing about this one is that the AI rotates immidiatly to the waypoint. I want that the player rotates as an animation I use JavaScript. And i dont want to use ITween. tank you

1 Answer

1

Use this:

var speed: float = 0.5;

function Update()
{
    var oldRot : Quaternion = transform.rotation;
    transform.LookAt (target);
    var newRot : Quaternion = transform.rotation;
    transform.rotation = Quaternion.Slerp (oldRot, newRot, speed * Time.deltaTime);
}

You can set the value of speed variable to change the speed of rotation.

If i do this the AI wil be stuck on the waypoint i have 3 waypoints and the AI is stuck on the first one.