Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Game Engines  ›  Capstone Project

Godot: Nodes, Scenes and GDScript

Godot 15 minGodot builds games from trees of nodes saved as reusable scenes, scripts them in Python-like GDScript, and calls _process every frame and _physics_process on a fixed physics tick.

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 * delta

The 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.

Harbour Hopper as Godot scenesStep 1 of 5
  1. crate.tscn

    A RigidBody2D root with Sprite2D and CollisionShape2D children, and a PhysicsMaterial with friction 0.25 and bounce 0.5.

Drills

Answer fast — trust the rule.

quick drill

What is a scene in Godot?

quick drill

Which callback should apply the drone's thrust?

quick drill

A crate rises up the screen in Godot 2D. What happens to its position.y?

quick drill

Godot's Transform2D holds two axis vectors and an origin. Which idea from this course is it?

quick drill

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.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainPlan Harbour Hopper in Godot

Plan Harbour Hopper in Godot. Name the scenes and key nodes you would create, say which callback applies the drone's thrust and why, and point out one sign you must flip compared with this course's side-view maths.