โœฆ JVDesignStudio ยท No Sign-Up Required

GDScript & Godot 4 Cheat Sheet

A one-page printable reference for variables, functions, signals, common nodes and the most-used code snippets in Godot 4. Pin it next to your monitor!

๐Ÿ“ฆ Variables & Types

var health: int = 100
var name: String = "Pip"
var speed: float = 4.5
var is_alive: bool = true
const MAX_HP = 100
@export var jump_force: float = 12.0

Use @export to edit a variable in the Inspector. const values can't change at runtime.

โš™๏ธ Functions

func _ready():
    # runs once when node enters scene
    print("Hello!")

func _process(delta):
    # runs every frame
    position.x += speed * delta

func take_damage(amount: int) -> void:
    health -= amount

๐Ÿ” Loops & Conditionals

if health <= 0:
    queue_free()
elif health < 20:
    print("Low HP!")
else:
    print("OK")

for enemy in get_tree().get_nodes_in_group("enemies"):
    enemy.queue_free()

while ammo > 0:
    ammo -= 1

๐Ÿ“ก Signals

signal health_changed(new_value)

func take_damage(amount):
    health -= amount
    health_changed.emit(health)

# connect in code:
player.health_changed.connect(_on_health_changed)

func _on_health_changed(value):
    hp_label.text = str(value)

Signals let one node tell other nodes when something happens no tight coupling needed.

๐ŸŽฎ Input & Movement

func _physics_process(delta):
    var dir = Vector2.ZERO
    dir.x = Input.get_axis("ui_left", "ui_right")
    dir.y = Input.get_axis("ui_up", "ui_down")
    velocity = dir.normalized() * speed
    move_and_slide()

    if Input.is_action_just_pressed("jump") and is_on_floor():
        velocity.y = JUMP_FORCE

๐ŸŒณ Node & Scene Basics

get_node("Path")Get a child node by path
$NodeNameShortcut for get_node("NodeName")
add_child(node)Add a node as a child
queue_free()Safely delete a node
get_parent()Reference the parent node
preload("res://x")Load a resource at compile time
instantiate()Create an instance from a PackedScene

๐Ÿงฑ Common Nodes

Node2DBase 2D node with position/rotation
CharacterBody2DPhysics body for players/enemies
Area2DDetects overlaps no collision response
Sprite2DDisplays a texture
AnimatedSprite2DPlays sprite animations
CollisionShape2DShape used for physics/areas
TimerFires a signal after a delay
AudioStreamPlayerPlays sound effects/music

โฑ๏ธ Built-in Callbacks (Lifecycle)

  • _init() โ€” object created (before scene tree)
  • _ready() โ€” node + children ready
  • _process(delta) โ€” every frame (variable rate)
  • _physics_process(delta) โ€” every physics tick (fixed rate)
  • _input(event) โ€” raw input events
  • _on_* โ€” convention for signal callback functions

๐Ÿ› ๏ธ Handy Snippets

# Change scene
get_tree().change_scene_to_file("res://levels/level_2.tscn")

# Random number / pick
var roll = randi() % 6 + 1          # 1-6
var pick = ["a","b","c"].pick_random()

# Wait / delay without freezing
await get_tree().create_timer(1.0).timeout

# Save / load a value
print(JSON.stringify({"score": 10}))

# Group nodes & call them all
get_tree().call_group("enemies", "take_damage", 5)

Want to build a whole game?

Follow one of our free step-by-step Godot 4 workshops in the Workshop hub.

๐Ÿ”ง Browse Workshops โ†’