Full basic tutorial: Gimbals on Godot engine

Difficulty understanding gimbals? then try Godot.
After opening the editor, possibly from version 3.0 and ON lets create a new project called ‘gimbal’.
One opened lets add a ‘spatial’ 3d node, on the left under the ‘scene’ tab.
Now add ‘CSGPolygon’ node, after lets click on Spatial in the scene menu and add another node, this time another ‘Spatial’ 3d node.
Right click on the last Spatial node and click rename, give it the name ‘InnerGimbal’. Now lets a Camera node. Your basic setup is now complete.

Now you can click on ‘Camera’ node, and move the camera according to best position to center the CSGPolygon(cube) by just draggin the arrows on it.
Now lets do the last part, add a script Spatial by right click then selecting ‘Attach script’ or click the icon with scroll and green arrow on top.
Lets past this in the new script:

extends Spatial

var rotation_speed = PI/2

func get_input_keyboard(delta):
	# Rotate spatial node around y axis
	var y_rotation = 0
	if Input.is_action_pressed("ui_right"):
		y_rotation += 1
	if Input.is_action_pressed("ui_left"):
		y_rotation += -1
	rotate_object_local(Vector3.UP, y_rotation * rotation_speed * delta)
	# Rotate inner gimbal(camera gimbal) around local x axis
	var x_rotation = 0
	if Input.is_action_pressed("ui_up"):
		x_rotation += -1
	if Input.is_action_pressed("ui_down"):
		x_rotation += 1
	$InnerGimbal.rotate_object_local(Vector3.RIGHT, x_rotation * rotation_speed * delta)
	self.rotate_object_local(Vector3.FORWARD, y_rotation * rotation_speed * delta)
func _process(delta):
	get_input_keyboard(delta)

Save, now click on ‘Play Scene’ or F6 and enjoy your gimbal movements by pushing up,down,left,right on keyboard!
p.s Some parts of the code are inspired by kidscandode opensource file. Thanks dude

Links
Download full project here: