Hello! Im am trying to get a spaceship working with full controll of rotation but it doesnt seem to work correctly. It is meant it going to go along a local axis but it has this wierd thing going on. I put the link here to a video to describe my problem. I included keyboard sound to make it clear when i click another button. This is my code:

func _physics_process(delta):
	if Input.is_action_pressed("Rotate_Forward"):
		rotation_degrees += transform.basis.x
	
	if Input.is_action_pressed("Rotate_Backward"):
		rotation_degrees -= transform.basis.x
	
	if Input.is_action_pressed("Tilt_Left"):
		rotation_degrees += transform.basis.y
	
	if Input.is_action_pressed("Tilt_Right"):
		rotation_degrees -= transform.basis.y
	
	if Input.is_action_pressed("RotateLeft"):
		rotation_degrees -= transform.basis.z
	
	if Input.is_action_pressed("RotateRight"):
		rotation_degrees += transform.basis.z

Thanks for you time!

This discussion was caught in the moderation queue since you have not confirmed your account yet.
Upon creating your account you should have received an account verification email. The confirmation email may have been incorrectly flagged as spam, so please also check your spam filter. Without confirming your account, future posts may also be caught in the moderation queue. You can resend a confirmation email when you log into your account if you cannot find the first verification email.
If you need any help, please let us know! You can find ways to contact forum staff on the Contact page. Thanks! :smile:

You can't rotate like that because of Gimbal lock (which will happen in any 3D engine if you don't account for it). See this tutorial for rotating a camera. The code should be exactly the same, you need a parent Spatial to hold the ship, then you can rotate in all directions. Just the first part under keyboard control is all you need. https://kidscancode.org/godot_recipes/3d/camera_gimbal/

2 years later