How to get Camera rotation AFTER rotating?

Hi there,

I am focussing the camera on an object using transform.LookAt. Now after that I want to 0 the z-axis to always have it straight. The problem is that I am doing this using:
transform.rotation=Quaternion.Euler(transform.rotation.x,transform.rotation.y,0);
But this always rotates the camera back to the initial rotation it had. Why is that? is transform.rotation giving back the rotation as it is before the LookAt? How to get the values after it?

Greetings

To find out what values transform.position are returning try doing a debug.log

Not sure if this will fix it, but you are giving quaternion x and ‘y’ values to your Euler method.
Try passing in transform.rotation.eulerAngles.x (and y) instead.

1 Like

Seems like it does. First test looks good. Thank you

Cool :slight_smile: you’re welcome.