I am working on a side-scroller - movement is restriced to the x and y planes. I’ve looked in several places on different forums and can’t find a good solution - I have a cylinder-like object that I want to point at the player at all times. I’ve tried several things but nothing keeps movement/rotation to the x and y planes. Any help is greatly appreciated.
Try using this script:
var Player : Transform; // probably assign this in editor
function Update(){
var point: Vector3 = Player.position
point.z = 0.0;
transform.LookAt (point);
}
And here's an explanation on how "transform.LookAt" works: http://unity3d.com/support/documentation/ScriptReference/Transform.LookAt.html