- Home /
rotating only on the Y-axis
I want to make my AI so it faces the player however My AI rotates on all axis making it unrealistic.
my code :
#pragma strict
var target : Transform;
function Update() {
transform.LookAt(target);
}
Comment
try this, transform.LookAt(target - mytransform);
add a variable that holds your transform marked as my transform.
Best Answer
Answer by robertbu · Jun 30, 2013 at 01:57 PM
#pragma strict
var target : Transform;
function Update() {
var lookPos = target.position;
lookPos.y = transform.position.y;
transform.LookAt(lookPos);
}
Your answer
Follow this Question
Related Questions
LookAt once 0 Answers
How to prevent Z axis rotation ? 1 Answer
How to prevent Z axis rotation ? 0 Answers
Angle to Rotate Vehicle in Scrolling in Environment 0 Answers
Lock rotation axis? 4 Answers