Lookling at Z position of a gameObject

hello, I would like to know if there is a script that makes a gameobject looking at an other gameObject but only its Z position …

if i’m not total wrong, this would only rotate the z axis based on the facing direction towards a target transform on z axis.

var oldRot = transform.EulerAngles;

transform.LookAt(targetTransform,Vector3.right);

transform.rotation = Quaternion.Euler(oldRot.x,oldRot.y,transform.EulerAngles.z);

thank you for the answer :smiley: It’s just that I was expecting a C# script