Hello, I am trying to write a very simple AI script that should have the AI object rotate to face the player. My code works except the AI rotates with an arc and I don’t understand why. I want it to sit still and rotate around it’s own y axis so that it always faces the player. Here is my code:
function Update () {
myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed * Time.deltaTime);
myTransform.eulerAngles = Vector3(0, transform.eulerAngles.y, 0);
}
Also I should point out I want this to work without the use of a character controller. Can someone give me an idea how to make this work properly? Thank you!