Free Resource

GDScript Cheat Sheet
Quick Reference for Godot 4

SScriptSnap/March 2026/12 sections/20+ patterns

Every GDScript pattern, syntax shortcut, and code snippet you'll actually use — organized in one place. Bookmark this page and stop Googling the same things over and over.

The first 4 sections are free to browse. Enter your email to unlock all 12 sections covering signals, exports, movement, tweens, state machines, and more.

var

Variables & Types

Variable declarations

Use var for mutable, const for compile-time constants, and static for shared state across instances.

basics.gd
var health: float = 100.0        # Typed mutable
var name := "Hero"               # Inferred type (String)
const MAX_SPEED: float = 400.0   # Compile-time constant
static var instance_count: int = 0  # Shared across instances

Core types

GDScript's built-in types cover everything from math to collections.

types.gd
var hp: int = 10
var speed: float = 3.14
var label: String = "Player"
var alive: bool = true
var pos: Vector2 = Vector2(100, 200)
var color: Color = Color.CORAL
var items: Array[String] = ["sword", "shield"]
var stats: Dictionary = {"atk": 5, "def": 3}

Enums

Define named constants for state machines, directions, and more.

enums.gd
enum State { IDLE, RUN, JUMP, FALL }
enum Element { FIRE = 10, ICE = 20, LIGHTNING = 30 }

var current_state: State = State.IDLE
var weakness: Element = Element.FIRE
fn

Functions

Function syntax

Type-annotate parameters and return values to catch bugs early and get autocomplete.

functions.gd
func heal(amount: float) -> void:
    health = min(health + amount, max_health)

func get_damage_multiplier(element: Element) -> float:
    if weakness == element:
        return 2.0
    return 1.0

# Lambda / callable
var double := func(x: int) -> int: return x * 2

Built-in virtual methods

Override these to hook into Godot's lifecycle. They're called automatically by the engine.

lifecycle.gd
func _ready() -> void:         # Node entered tree
    pass
func _process(delta: float) -> void:  # Every frame
    pass
func _physics_process(delta: float) -> void:  # Fixed timestep
    pass
func _input(event: InputEvent) -> void:  # Raw input
    pass
func _unhandled_input(event: InputEvent) -> void:
    pass
if

Control Flow

Conditionals & matching

match is GDScript's pattern-matching — like switch but more powerful.

control.gd
# If / elif / else
if health <= 0:
    die()
elif health < 30:
    play_low_hp_warning()
else:
    regenerate()

# Match (pattern matching)
match state:
    State.IDLE:
        play_idle_anim()
    State.RUN:
        velocity.x = direction * speed
    State.JUMP, State.FALL:
        apply_gravity(delta)
    _:
        push_warning("Unknown state")

Loops

for-in works on ranges, arrays, dictionaries, strings, and nodes.

loops.gd
# Range loop
for i in range(5):         # 0,1,2,3,4
    print(i)

# Array loop
for item in inventory:
    item.use()

# Dictionary loop
for key in stats:
    print("%s: %d" % [key, stats[key]])

# While loop
while not is_on_floor():
    velocity.y += gravity * delta
    move_and_slide()
~>

Signals

Signal basics

Signals are Godot's observer pattern. Declare, connect, emit — zero coupling.

signals.gd
# Declare
signal health_changed(new_hp: float)
signal died

# Emit
func take_damage(amount: float) -> void:
    health -= amount
    health_changed.emit(health)
    if health <= 0:
        died.emit()

# Connect (from another node)
func _ready() -> void:
    player.health_changed.connect(_on_hp_changed)
    player.died.connect(_on_player_died)

Signal bus pattern

A global autoload that acts as a central event dispatcher. No more get_node spaghetti.

event_bus.gd
# Autoload as "Events"
extends Node

signal player_damaged(amount: float)
signal coin_collected(value: int)
signal level_completed
signal game_paused(is_paused: bool)

# Any node can emit:
#   Events.player_damaged.emit(25.0)
# Any node can listen:
#   Events.coin_collected.connect(_on_coin)
8 more sections below

Unlock the Full Cheat Sheet

Get instant access to all 12 sections covering 18+ patterns, plus weekly GDScript tips delivered to your inbox. Free forever.

@@export Annotations
$Node References
->Movement Patterns
>>Async & Timing
{}Custom Resources
++Scene Instantiation
<>Tweens & Animation
SMState Machines
>

No spam. Unsubscribe anytime.

>> EOF
15-min micro-courses

Want to Go Deeper?

This cheat sheet gives you the syntax. Our micro-courses teach you the why and when — with hands-on video walkthroughs you can follow in your own Godot editor.

Browse Courses

More free resources

We publish free GDScript tutorials every week covering signals, shaders, state machines, multiplayer, and more. Read our latest tutorial →