Hi!
I’m wondering if its posssible to use lookAt constrained to a single axis, is there any way to do this?
Thanks!
-Chris
Yes, if I remember correctly it would look like this.
var target : Transform;
function Update(){
transform.LookAt(target.position.x, transform.position.y, target.position.z);
}
the above is set up to lock rotation on the y axis (I believe). I’m sure you could figure out how to do it for whatever axis you need (you may need to mess around with it a little).
The usual solution is (e.g.):
var targetPosition = target.position;
targetPosition.y = transform.position.y;
transform.LookAt(targetPosition);
There are other ways it can be expressed, but the idea is the same.