Back

How This Course Uses Godot

divider

Godot lets you build a game a hundred different ways. That flexibility is great once you know what you are doing, and confusing before then — every tutorial you find online will do things a little differently, and none of them will explain why.

This page is the way we do it in this class. Five rules, and the reason for each one. Every activity assumes them, so when a video online does something that contradicts a rule here, the rule here wins.

divider

The Version

This course uses Godot 4.7. Every screenshot, every menu, and every property name in these activities comes from that version.

Godot changes between versions. If you install a different one at home, buttons will have moved and some things will be named something else. Use 4.7 and the pictures will match what is on your screen.

divider

A Scene Is a Reusable Object

This is the single most important idea in Godot, and it is the one people find strangest coming from other engines.

A scene is a saved .tscn file describing an object and everything it is made of. Once saved, you can drop as many copies of it into your game as you like, and every copy behaves the same way.

Read a scene like this:

  • The root node is the thing itself — the crate, the player, the bullet.
  • Its children are the parts it is made of — a sprite so you can see it, a collision shape so it can be hit, a timer, a sound.
  • Dropping a copy into your level is called instancing. Each copy is an instance.

A "scene" does not have to mean a whole level. A single crate is a scene. A bullet is a scene. Your level is also a scene, one that happens to contain instances of the others.

divider

The Five Rules


1. Scripts go on root nodes only

A script attaches to the root of a scene, never to one of its children. The crate's script goes on the crate, not on the crate's sprite.

Why. If every part of an object can have its own script, then finding the code that controls something means hunting through the whole tree. One object, one script, one place to look.


2. Two levels deep, no more

A scene is a root and its parts. Parts do not get their own parts.

Why. Deep trees are where beginners get lost, and they are also fragile — the deeper a node sits, the more ways there are for a path to it to break. If you find yourself needing a third level, that is usually a sign the thing you are nesting should be its own scene.


3. Grab your nodes once, at the top

When a script needs to talk to one of its own parts, grab a reference at the top of the file and use that name everywhere else.

player.gd
extends CharacterBody2D
@onready var sprite: Sprite2D = $Sprite2D
@onready var shape: CollisionShape2D = $CollisionShape2D
func _physics_process(delta: float) -> void:
sprite.flip_h = velocity.x < 0.0

Never go looking for a node in the middle of your logic:

# Don't do this. It breaks the moment anyone moves a node.
get_node("../../Player/Sprite2D").flip_h = true

Why. That second version is a string describing a route through the tree. Rename a node or drag it somewhere else, and the string is still perfectly valid text that now points at nothing. Your game breaks at run time, with an error that does not mention the thing you actually changed.


4. Signals announce, they don't command

Use a signal when an object needs to announce that something happened and does not care who is listening — "I died", "I was collected", "the timer ran out".

When you know exactly which object you want to act on, just call its function directly.

Why. Signals are genuinely useful, and Godot tutorials use them for everything, including cases where a plain function call would be shorter and clearer. Once a project has twenty signals in it, tracing what happens when you press a button means opening twenty files.


5. One folder per scene

Everything that belongs to an object lives in one folder with it — its scene, its script, its art.

crate/
crate.tscn
crate.png
ball/
ball.tscn
ball.png
main/
main.tscn
main.gd

Why. The alternative — all scenes in one folder, all scripts in another, all art in a third — looks tidy for about a week. Then you have forty files in three folders and deleting an object means hunting its pieces down one at a time.

divider

Naming

Godot is picky about this, and so is this class.

ThingStyleExample
NodesPascalCaseCollisionShape2D
Scene fileslowercasecrate.tscn
Variablessnake_caselaunch_power
Functionssnake_casereset_scene()
ConstantsALL_CAPSLAUNCH_POWER

GDScript uses indentation to decide what belongs inside what — there are no curly braces. A tab in the wrong place changes what your program does, so let the editor indent for you and do not fight it.

divider

The Short Version

  1. Scripts go on root nodes only.
  2. Two levels deep, no more.
  3. Grab your nodes once, at the top.
  4. Signals announce, they don't command.
  5. One folder per scene.

Come back to this page whenever a tutorial has you doing something that feels tangled. Usually it is breaking one of these five.