Menu
CoddyTech

Spin With Rotation

Part of the Nodes and Scenes section of Coddy's Godot journey. Lesson 11 of 27.

A node turns around its own position. rotation is how far it has turned, in radians. A whole turn is 2 * PI radians, about 6.28. rotation_degrees is the same angle in degrees, where a whole turn is 360. Change one and the other follows.

rotation_degrees = 90   # a quarter turn
rotation = PI / 2      # the same quarter turn

A growing angle turns a node clockwise. To spin, add to the angle on every frame, times delta:

func _process(delta):
	rotation_degrees += 90 * delta

That spins a quarter turn each second. -= spins the other way.

challenge icon

Challenge

Easy

Make the robot spin clockwise, half a turn every second, in the place where it stands.

Try it yourself

extends Node2D

func _process(delta):
	pass
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Nodes and Scenes

Practice on your own: Godot playground