- Home /
How to turn camera using LookAt() only along X and Y axis?
Hi guys,
I need to turn camera to face certain object in 3D space but I want it not to change its z-axe rotation. When I try using transform.LookAt camera turns along all 3 axis. However I only want to adjust x- and y-axe rotation of camera to face the object (no metter how rotated is the object). Any idea how to do that in C# script?
Thanx in advance for any replies.
Comment
Best Answer
Answer by Pecek · Aug 20, 2014 at 06:28 PM
Write your own function for this, or store the Z value before the rotation and assign it back
z = transform.eulerAngles.z
tranform.LookAt(object)
transform.eulerAngles.z = z
Something like this.