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.

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.