Menu
CoddyTech

Turn the Ship

Part of the Projects section of Coddy's Godot journey. Lesson 11 of 36.

The next project is an asteroid shooter. A ship turns, thrusts and shoots drifting rocks. You win when no rocks are left, and lose if one hits the ship.

The scripts are ship.gd, rock.gd and main.gd. Start with the ship. It does not slide like the paddle. It turns: Left and Right change its rotation, in radians.

rotation += Input.get_axis("move_left", "move_right") * TURN_SPEED * delta

A full turn is about 6.28 radians. With a TURN_SPEED of 4, a full turn takes about a second and a half. A positive rotation turns clockwise.

challenge icon

Challenge

Easy

Turn the ship with the arrow keys.

  1. In ship.gd, add const TURN_SPEED = 4.0.
  2. In _physics_process, turn the ship with Left and Right at TURN_SPEED radians per second. Right turns it clockwise.

Press Play and hold Right: the ship spins clockwise. Then Check.

Try it yourself

extends CharacterBody2D

func _physics_process(delta):
	pass

All lessons in Projects

Practice on your own: Godot playground