Hi, I have a script on my enemy AI script which is in charge of making sure the enemy always looks at the player, it works but the problem is that if the player is above or below the enemy the latter will rotate on the z and x axis to look up or down, which doesnt look good at all.
Im trying to find a way to lock the rotation to the y axis only but I cant figure it out, here’s the code I have handling the rotation:
var Damping:float = 6.0; // Rotation damping speed
function lookAt ()
{
var rotation = Quaternion.LookRotation(Target.position - transform.position);
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * Damping);
}
Any pointers?
That worked, thanks a bunch!
– AlejandroGorgal