Turn the Ship
Part of the Projects section of Coddy's Godot journey. Lesson 10 of 33.
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 * deltaA 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
EasyIn ship.gd, add const TURN_SPEED = 4.0 and turn the ship with Left and Right in _physics_process, at TURN_SPEED radians per second. Right turns it clockwise.
Try it yourself
extends CharacterBody2D
func _physics_process(delta):
pass
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Projects
2Project: Asteroid Shooter
Turn the ShipFire the EnginePractice on your own: Godot playground