TExcelTAD
Home › Godot 4 with GDScript › Godot Intro

Godot Intro

Godot is a free, open-source game engine for 2D and 3D games. It is released under the MIT licence: no royalties, no account, no splash-screen requirement, and the whole engine (editor included) is one download of roughly 100 MB that runs without installation. Games built with it ship to Windows, macOS, Linux, Android, iOS and the web, and to consoles through third-party porting companies.

This course targets Godot 4.x and was checked against Godot 4.7. Godot 3 projects, tutorials and answers are still everywhere online, and many of their APIs were renamed in Godot 4 (KinematicBody2D became CharacterBody2D, yield became await, export var became @export var, TileMap was replaced by TileMapLayer). When a search result uses those names, it is about Godot 3.

What you need first

How this course works

Most examples are GDScript, Godot's built-in language. Godot can't run inside a web page, so the GDScript playgrounds on this site show the output that was recorded when the script ran in real Godot 4.7 (headless), and every example is re-checked against Godot whenever the course is verified. You can edit the code and copy it into your own project.

There are two kinds of runnable script:

  1. A script that extends SceneTree is a tiny program: the code in _init() runs once and quit() ends it. Language lessons use this form.
  2. Any other script (extends Node, Node2D, CharacterBody2D, ...) is attached to a node called Main and added to a running scene tree, so _ready(), _process() and _physics_process() run as they would in a game. Physics, timers, tweens and signals all work. Only rendering and real keyboard input are missing, so input is simulated in code.

Here is the smallest program:

gdscript · try it yourself
extends SceneTree

func _init():
	var engine := "Godot"
	var major: int = Engine.get_version_info().major
	print("Hello from ", engine, " ", major)
	quit()
Hello from Godot 4

And here is a node that moves for three frames. The test runner fixes the frame rate at 60 FPS, so delta is always 1/60 of a second and the output is the same on every run:

gdscript · try it yourself
extends Node2D

# frames: 3
var speed := 90.0  # pixels per second

func _ready():
	print("Ready at ", position)

func _process(delta):
	position.x += speed * delta
	print("x = ", position.x)
Ready at (0.0, 0.0)
x = 1.5
x = 3.0
x = 4.5

Editor workflows (clicking through docks, connecting signals in the inspector), scene files (.tscn), shaders, 3D scenes and C# are shown as ordinary code blocks with numbered steps, because they need the editor or a GPU.

Godot in one picture

Idea In Godot
The building block a node: Sprite2D, CharacterBody2D, Camera3D, Label, Timer, AudioStreamPlayer ... about 200 types
A reusable object a scene: a tree of nodes saved as a .tscn file. A player, a coin, a level and a menu are all scenes
The running game the scene tree: one root viewport with your current scene (and autoloads) under it
Behaviour a script attached to a node, extending that node's class
Communication signals (events) going up, method calls going down
Data resources: textures, sounds, materials and your own data classes, saved as .tres/.res

Unity users: a scene is closer to a prefab than to a Unity scene, a node is a GameObject and a component in one, and signals replace most UnityEvent and C# event wiring. Compare with the Unity course if you know it.

Your first project

  1. Download Godot 4 from godotengine.org (the standard build, unless you want C#; see Godot Builds, VS Code & the Debugger). Unzip and run it.
  2. In the Project Manager, click Create, give the project a name, choose an empty folder and keep the default renderer (Forward+ for desktop, Mobile or Compatibility for phones and the web).
  3. In the Scene dock, click 2D Scene. A Node2D root appears. Right-click it, choose Attach Script, and accept node_2d.gd.
  4. Replace the script with the moving example above and press Ctrl+S to save the scene as main.tscn.
  5. Press F5 (Run Project). Godot asks for a main scene: choose Select Current. The Output panel shows the prints.

What's in the course

Section You learn
Getting Started the editor, nodes and scenes, instancing, the lifecycle, project settings, autoloads
GDScript syntax, collections, static typing, classes, @export, @onready, signals, await, resources
2D CharacterBody2D, platformer movement, areas and raycasts, TileMapLayer, animation, Camera2D
3D transforms and Basis, CharacterBody3D, materials and lighting, navigation
Systems the input map, UI, audio buses, saving, groups, timers, tweens, a state machine
C#, Shaders & Shipping C# in Godot, the shading language, exports, GDExtension
Toolkit & Field notes builds, editors, the debugger, addons, testing, hard-won advice

You finish with Coin Climber, a small platformer whose game logic you can run and test.

Test yourself

What is a Godot scene?

  1. Only a whole level
  2. A tree of nodes saved as a reusable file (.tscn)
  3. A C# class
  4. A folder in the project

You find a tutorial that uses KinematicBody2D and yield. What does that tell you?

  1. It is for Godot 4.7
  2. It is written for Godot 3; Godot 4 uses CharacterBody2D and await
  3. It uses C#
  4. It is about 3D games only

In the second example, why is x exactly 1.5 after the first frame?

  1. Godot always moves 1.5 pixels per frame
  2. speed (90) times delta (1/60 s at a fixed 60 FPS) is 1.5
  3. position starts at 1.5
  4. _process runs 90 times per second