Rotation problem!!! Pls help me!

Why I have this problem??? I make this script (it’s a test) :

function Update () 
{
	if(Input.GetKey(KeyCode.LeftShift))
	{
		if(Input.GetKeyDown(KeyCode.UpArrow))
		{
			transform.rotation.x += 90;
		}
		if(Input.GetKeyDown(KeyCode.DownArrow))
		{
			transform.rotation.x -= 90;
		}
		if(Input.GetKeyDown(KeyCode.LeftArrow))
		{
			transform.rotation.z += 90;
		}
		if(Input.GetKeyDown(KeyCode.RightArrow))
		{
			transform.rotation.z -= 90;
		}
	}
	
}

When I press Shift + UpArrow (or other Arrow) the script don’t add 90° to the transform rotation but make x-axis 0.(+something), y-axis = 180, z-axis = 180. I attach to the post package with the example. Pls help me it’s important!

513447–18260–$RotationProblem.unitypackage (6.76 KB)

Hello there!

The reason it’s not working is because you’re trying to handle the rotation which is a quaternion as euler-angles.
Replace your rotation lines according to this:

transform.Rotate(new Vector3(90, 0, 0));

Thanks, it works but i would add to x-axis 90° not set x-axis to 90°. Can you help me?

From the documentation:

function Rotate (eulerAngles : Vector3, relativeTo : Space = Space.Self) : void

Description

Applies a rotation of eulerAngles.z degrees around the z axis, eulerAngles.x degrees around the x axis, and eulerAngles.y degrees around the y axis (in that order).

Looks to me like it does rotate by 90, not set rotation to 90.