- Home /
Question by
Tomas_D · Dec 24, 2012 at 05:51 AM ·
rotationaiquaternionslerplookrotation
Basic AI Locked Axis
Ok I've been looking on this form, the Script Reference and searching several tutorials and I can't seem to find the answer to this question "How to make a basic AI similar to 3D platformer enemies that only rotate to look at the player on one axis. Every were I look all I find is this code.
function Update ()
{
myTransform.rotation = Quaternion.Slerp (myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), Time.deltaTime);
}
But this rotates the enemy on all axis so if my player character jumps and there is a forward translate added the enemy floats upward to meet him in the air. How do I restrict the axis or is this not the right method for doing this kind of AI?
Comment
Best Answer
Answer by Tomas_D · Dec 30, 2012 at 04:57 PM
Found the answer here: http://forum.unity3d.com/threads/36377-transform.LookAt-or-Quaternion.LookRotation-on-1-axis-only