How to set Z axis to 0

Hello everyone,
I am currently creating a 3D game, and i need a script that would set Z camera axis to 0, but without changing the other rotation. Do anyone know how to do this ?
Thank you

Hello, you need to be more clear with what happens to you right now, and what you’ve tried and it didn’t work.
Otherwise, you’re probably explaining what you think is wrong and the most likely thing that is wrong is your assumption.

A screenshot would help as well when you’re talking about rotations.

Here is one way:

Vector3 c = Camera.main.transform.rotation.eulerAngles;
Camera.main.transform.rotation = Quaternion.Euler( c.x, c.y, 0 );

You could do something like this, where you set z to 0 and you set x and y to the same value that they already are.

transform.EularAngles =new Vector3(transform.EularAngles.x, transform.EularAngles.y, 0);

who’s Eular? :slight_smile:

Btw, let’s not jump to conclusions, I’m pretty positive the OP has the issue with a compound rotation, which cannot be solved with the Euler function