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.
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.
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:
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.
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.
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.
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.
extends CharacterBody2D
@onready var sprite: Sprite2D = $Sprite2D@onready var shape: CollisionShape2D = $CollisionShape2D
func _physics_process(delta: float) -> void: sprite.flip_h = velocity.x < 0.0Never 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 = trueWhy. 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.
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.
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.gdWhy. 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.
Godot is picky about this, and so is this class.
| Thing | Style | Example |
|---|---|---|
| Nodes | PascalCase | CollisionShape2D |
| Scene files | lowercase | crate.tscn |
| Variables | snake_case | launch_power |
| Functions | snake_case | reset_scene() |
| Constants | ALL_CAPS | LAUNCH_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.
Come back to this page whenever a tutorial has you doing something that feels tangled. Usually it is breaking one of these five.