How set rotation of a single axis

I am making a spaceship game, and in the game the ship can move forward, backwards, right, and left, and it can turn up, down, right and left. The problem is with the two-axis turning: when you turn one way and then the other, you end up in a roll position. Is there a way to set the rotation so as to prevent a roll without resetting all the rotation axis’s value? In other words, is there a way to set the x-rotation to, say, 0 from whatever it is without changing y and z?

Hey there. Not 100% sure it will work but maybe you could try using this:

yourObjectName.transform.Rotate(yourXVariable, yourObjectName.y, yourObjectName.z)

Make a float for the x variable and change ‘yourXVariable’ with that float. Or you could just set that x value to any number.

Hopefully it works! :smiley: