// The target variable shows up as a property in the inspector.
// Drag another object onto it to make the camera look at it.
var target : Transform;
// Rotate the unit every frame so it keeps looking at the target
function Update() {
transform.LookAt(target);
}
It must be simple but it is me after all …
How do I make this transform happen only in the Y-axis, so that the object it’s attached to only rotates around the Y axis to look at the target?
Gracias.
Reading Carefully (^_^) the code isn’t (target, target, target), it’s (target, THISTRANSFROM, target) which is why it works.
The summation of the code should be:
var thisTransform : Transform;
var target : Transform;
function Start/Awake () {
thisTransform = this.Transform;
}
function Update() {
thisTransform.LookAt(Vector3(target.position.x, thisTransform.position.y, target.position.z));
}
What I’m finding with this code, is that is seems to monkey with the physics of the object that’s using it, but this is probably an issue with LookAt(), rather than ignoring the Y.