Godot: Nodes, Scenes and GDScript
Godot is free and open source, quick to download, and built around one idea that makes Harbour Hopper fall neatly into place: everything is a node. It's a good engine in which to watch every section of this course turn up at once.
The rule
Everything is a node; a scene is a node tree you can reuse.
A node does one job. Sprite2D draws an image, CollisionShape2D gives a physical shape, RigidBody2D puts something under physics, Camera2D looks at the world. Nodes are arranged in a tree, and a tree saved to a file is a scene. Scenes can be instanced inside other scenes, so the crate scene can appear dozens of times inside the harbour scene, much like a prefab.
Nodes talk to each other through signals. A node announces that something happened, such as a body entering an area, and every node connected to that signal reacts.
Scripts are usually written in GDScript, a language made for Godot with syntax much like Python's; C# is supported too. Two callbacks map straight onto Section 1:
_process(delta)runs every frame, with the delta time in seconds;_physics_process(delta)runs on the fixed physics tick, 60 times a second by default.
extends Node2D
var speed := 180.0 # a drifting cloud; Godot 2D measures in pixels
func _process(delta: float) -> void:
position.x += speed * deltaThe maths types are old friends: Vector2 and Vector3; Transform2D, which holds two axis vectors and an origin (an affine transformation); Basis and Transform3D for 3D; and Quaternion. A PhysicsMaterial holds friction and bounce.
One sign needs care: in Godot's 2D world, y points down, like rows of screen pixels. Our side view's "up" is negative y there, and gravity is positive. In Godot's 3D world, y points up again.
The shortcut
Think in scenes, and flip y in 2D. Give each thing in the game its own scene, put forces in _physics_process, and negate every vertical number from this course when you work in 2D.
crate.tscn
A
RigidBody2Droot withSprite2DandCollisionShape2Dchildren, and a PhysicsMaterial with friction 0.25 and bounce 0.5.
Drills
Answer fast — trust the rule.
What is a scene in Godot?
Which callback should apply the drone's thrust?
A crate rises up the screen in Godot 2D. What happens to its position.y?
Godot's Transform2D holds two axis vectors and an origin. Which idea from this course is it?
GDScript's syntax is closest to which language?
Remember
- Everything is a node; scenes are saved node trees you can instance many times.
_process(delta)runs per frame;_physics_process(delta)runs on the fixed tick and is where forces go.- In Godot 2D, y points down: flip the vertical signs from this course.
