I have two gameobjects in a scene. My base object and a target object. I want the base object to rotate along it's Y axis to face or look at, the target object. How do I constrain the rotation of the base object to just the Y axis?
I have tried a slew of different ways to do this, with no luck.
I've also tried just using Transform.LookAt(targetPoint) with no luck either.
How can I constrain to just one axis (the Y-axis)? I don't care that the two objects are facing in the same direction, but what I'm trying to do is have the base object look at the target object with a fixed rotation axis. Thanks!
I used this to rotate an NGUI label to always point at the player while only rotating in the Y. Attach it to what ever object you want to “look at” the player
function Rotate (xAngle : float, yAngle : float, zAngle : float, relativeTo : Space = Space.Self) : void
var y = //Whatever you want the y to be, being the targets y, just put this in the update function (Without the var).
function Update(){
y = //Same thing here;
transform.Rotate(0, y, 0, Space.World);
}