# Rotation Locks at 90 or 270 degrees

Hey everyone,

I’m coding a space ship object the player can rotate, and due to some weird behavior from the rigidbody’s torquing, I’m rewriting it with localEulerAngles. So far it all works perfectly, except the X axis pitch.

What is happening is once my ship gets near 90 or 270 on the X axis, the X axis locks into place at 90 or 270 and I’m only able to rotate around the Z axis. I’ve made sure that nothing else I’ve written is interfering with this code by putting it into another script object, but it still does this. Is this just a quirk of Unity? Is there a way to address this?

``````public var rotationThrust : float = 0.3;  // The thrusting power for rotation

private var rot_Pitch : float;
private var rot_Yaw : float;
private var rot_Roll : float;

function Update () {

// ROTATIONAL THRUSTERS
var p = Input.GetAxisRaw("Pitch");
var y = Input.GetAxisRaw("Yaw");
var r = Input.GetAxisRaw("Roll");

if (p)
rot_Pitch += rotationThrust * p;

if (y)
rot_Yaw += rotationThrust * y;

if (r)
rot_Roll += -rotationThrust * r;

// ROTATE SHIP
transform.localEulerAngles.x += rot_Pitch * Time.fixedDeltaTime;
transform.localEulerAngles.y += rot_Yaw * Time.fixedDeltaTime;
transform.localEulerAngles.z += rot_Roll * Time.fixedDeltaTime;

}
``````

As the docs say, “Only use this variable to read and set the angles to absolute values. Don’t increment them, as it will fail when the angle exceeds 360 degrees. Use Transform.Rotate instead.” (Also, localEulerAngles is for objects that have parents; presumably you meant eulerAngles, although as mentioned I’d recommend not using that either.)