Spaceship gets stuck at transform.eulerAngles.x =270

I want my spaceship to loop the loop when i press up, to loop 360’ , but it climbs to vertical and then it stays stuck upwards at transform.eulerAngles.x =270 and then when i press the buttons it just vibrates in stuck position.

          if(Input.GetKey("w"))//------ NAVIGATION ----------
 { 
		  transform.eulerAngles.x += rotspd * Time.deltaTime * 7;
 }			 
 
      if(Input.GetKey("s"))
 { 
		  transform.eulerAngles.x += -rotspd * Time.deltaTime * 7;
 }		

i added this to prevent it becoming stuck at 270, but i still cant go more than 270’, i.e. straight up.

if(transform.eulerAngles.x==270 )//------ stops it gettign stuck at 270degrees
 { 
		   transform.eulerAngles.x=275;
 }

You can’t use EulerAngles like that. Internally, Rotations are stored as Quaternions and there are more than one set of EulerAngles describing the same Quaternion, so what you put into EulerAngles might not stay the same.

A fast fix for your problem would be to keep your angle in a float and only change that float and only write to the eulerAngles, never read from them.

if(Input.GetKey("w"))
{ 
   rotX += rotspd * Time.deltaTime * 7;
}        
if(Input.GetKey("s"))
{ 
   rotX += -rotspd * Time.deltaTime * 7;
}

transform.eulerAngles = new Vector3(rotX,0,0);

btw, what’s doing the 7 there? This should be in rotspd. Multiplay you rotspd by 7.

The above should fix your problem. If you need to rotate around another axis, you may still experience gimbal lock, but that’s for another time - maybe read up on “gimbal lock” first… and it may not apply to your situation