- Home /
LookAt something while rotating on z?
How do you get an object to do a LookAt while enabling transform.rotate on its z? I just realized that using LookAt forces the y axis to look upward, disabling the possibility for rotating on the z axis. I need the object to to both at the same time in Update.
Thanks
Comment
Answer by Owen-Reynolds · Jun 09, 2012 at 07:37 AM
LookAt has an optional 2nd parm for the local y-axis, which merely defaults to world-Y. To sort of preserve the current up, could do:
Vector3 oldY = transform.up;
transform.LookAt(target, oldY);