Learning Hub

Everything you need to build games

Open Learning Hub
Getting Started

Unreal to Godot Guide

Transitioning from Unreal Engine to Godot 4? Learn how Blueprints map to GDScript, Actors ...

+100 XP 15 min
Getting Started

Unity to Godot Guide

Switching from Unity to Godot? This migration guide maps Unity concepts to Godot equivalen...

+100 XP 15 min
Fundamentals

Node Tree Explorer

Understand Godot's node and scene system from scratch. Learn how nodes work, how to compos...

+50 XP 10 min
Fundamentals

Translation Game

Match Unity and Unreal Engine terms to their Godot equivalents in this interactive quiz ga...

+40 XP 8 min
Fundamentals

Code Lab

Side-by-side code comparisons between C# (Unity) and GDScript (Godot). See how familiar co...

+60 XP 12 min
Core Systems

Input Guide

Learn about Input Actions, events, and handling player control in Godot 4. Master keyboard...

+45 XP 10 min
Core Systems

Physics Guide

Learn RigidBody, CharacterBody, collisions, and physics layers in Godot 4. Complete 2D and...

+55 XP 12 min
Core Systems

Save & Load Guide

Build robust save systems with JSON, FileAccess, and auto-save features in Godot 4....

+55 XP 15 min
Interactive Labs

Scene Builder

Drag and drop to build a Godot scene tree from scratch. Interactive exercise to practice n...

+65 XP 12 min
Interactive Labs

Input Playground

Real-time input testing playground. Press keys and see Godot's input system respond instan...

+50 XP 8 min
Interactive Labs

Code Sandbox

Write and run GDScript directly in your browser. Practice Godot scripting with instant fee...

+80 XP 15 min
Reference

Editor Guide

Master the Godot Editor: panels, shortcuts, hidden features, and productivity tips for eff...

+45 XP 10 min
Reference

Asset Pipeline Guide

Import 3D models, audio, textures, particles, and more into Godot 4. Complete asset pipeli...

+45 XP 12 min
Advanced

Real World Patterns

Learn essential design patterns implemented in GDScript for Godot 4: Singleton, Observer, ...

+90 XP 15 min
Reference

GDScript Cheat Sheet

Complete GDScript cheat sheet for Godot 4. Variables, functions, signals, exports, types, ...

+30 XP 5 min

GDScript Recipes

Copy-ready code for common patterns

All Recipes
Movement

2D Player Movement

Basic WASD/arrow key movement for CharacterBody2D

extends CharacterBody2D

var speed = 300.0

func _physics_process(delta):
    var direction = Input.get_vector("left", "right", "up", "down")
    velocity = direction * speed
    move_and_slide()
Open Guide
Movement

Top-Down 8-Direction Movement

Normalized 8-direction movement with acceleration and friction

extends CharacterBody2D

@export var max_speed := 200.0
@export var acceleration := 1200.0
@export var friction := 1000.0

func _physics_process(delta):
    var input_dir = Input.get_vector("left", "right", "up", "down")
Open Guide
Movement

Smooth Camera Follow

Camera2D that smoothly tracks a target node with offset and dead zone

extends Camera2D

@export var target: Node2D
@export var smoothing := 5.0
@export var offset := Vector2(0, -40)
@export var look_ahead := 50.0

func _process(delta):
Movement

Platformer Jump with Gravity

Variable-height jump with coyote time and jump buffering

extends CharacterBody2D

@export var speed := 300.0
@export var jump_force := -400.0
@export var coyote_time := 0.12
@export var jump_buffer_time := 0.1

var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
Open Guide
UI

Health Bar with Tween

Animated health bar that smoothly transitions when health changes

extends ProgressBar

@export var health_component: Node

func _ready():
    if health_component:
        health_component.health_changed.connect(_on_health_changed)
    max_value = 100
UI

Damage Numbers Popup

Floating damage numbers that rise and fade out when enemies take hits

extends Node2D

# Call this to spawn a damage number
func show_damage(amount: int, pos: Vector2, is_crit := false):
    var label = Label.new()
    label.text = str(amount)
    label.position = pos
    label.horizontal_alignment = HORIZONTAL_ALIGNMENT_CENTER
UI

Screen Shake Effect

Camera shake effect triggered by events like explosions or damage

extends Camera2D

var shake_intensity := 0.0
var shake_decay := 5.0

func shake(intensity := 10.0, duration := 0.3):
    shake_intensity = intensity
UI

Menu Slide Transitions

Smooth panel transitions for navigating between menu screens

extends Control

@onready var panels = [$MainMenu, $SettingsMenu, $CreditsMenu]
var current_panel: Control

func _ready():
    current_panel = $MainMenu
    for panel in panels:
Signals

Custom Signal with Data

Define and emit custom signals that carry typed payload data

extends CharacterBody2D

signal health_changed(old_value: int, new_value: int)
signal died
signal item_collected(item_name: String, quantity: int)

var health := 100
Open Guide
Signals

Connecting Signals in Code

Connect signals programmatically with lambdas and bound arguments

extends Node

func _ready():
    # Basic connection
    $Player.health_changed.connect(_on_health_changed)
    $Player.died.connect(_on_player_died)

    # Lambda connection
Open Guide
Signals

Signal Bus (Autoload)

Global event bus pattern using an autoload singleton for decoupled communication

# EventBus.gd — Add as Autoload in Project Settings
extends Node

# Game state signals
signal game_started
signal game_paused(is_paused: bool)
signal game_over(score: int)
Open Guide
Save/Load

JSON Save System

Save and load game data as JSON files with error handling

extends Node

const SAVE_PATH = "user://savegame.json"

func save_game(data: Dictionary) -> bool:
    var file = FileAccess.open(SAVE_PATH, FileAccess.WRITE)
    if not file:
        push_error("Cannot open save file: " + str(FileAccess.get_open_error()))
Open Guide
Save/Load

Resource-Based Save

Type-safe save system using custom Resource classes

# save_data.gd
class_name SaveData
extends Resource

@export var player_name := "Hero"
@export var level := 1
@export var health := 100
@export var position := Vector2.ZERO
Open Guide
Save/Load

Config File Settings

Store user preferences (volume, resolution, keybinds) with ConfigFile

extends Node

const CONFIG_PATH = "user://settings.cfg"

func save_settings(settings: Dictionary):
    var config = ConfigFile.new()

    config.set_value("audio", "master_volume", settings.get("master_volume", 1.0))
Open Guide
Physics

Raycasting from Code

Cast rays to detect walls, ground, or line-of-sight between objects

extends CharacterBody2D

func check_line_of_sight(target: Node2D) -> bool:
    var space = get_world_2d().direct_space_state
    var query = PhysicsRayQueryParameters2D.create(
        global_position,
        target.global_position,
        1  # Collision mask
Open Guide
Physics

Area2D Detection Zone

Detect when bodies enter/exit an area for pickups, triggers, or aggro zones

extends Area2D

signal body_detected(body: Node2D)
signal body_lost(body: Node2D)

var bodies_in_range: Array[Node2D] = []

func _ready():
Open Guide
Physics

Projectile Spawning

Spawn and fire projectiles with speed, direction, and lifetime

# bullet.gd
extends Area2D

var speed := 600.0
var direction := Vector2.RIGHT
var damage := 10

func _ready():
Open Guide
Audio

Play Sound Effects

Play one-shot SFX with pitch variation using AudioStreamPlayer

extends Node

@export var sfx_library: Dictionary = {}

# Preload your sounds
var sounds = {
    "jump": preload("res://audio/sfx/jump.wav"),
    "hit": preload("res://audio/sfx/hit.wav"),
Audio

Background Music with Crossfade

Crossfade between background music tracks with volume tweening

extends Node

var current_player: AudioStreamPlayer = null

func play_music(stream: AudioStream, fade_duration := 1.0):
    var new_player = AudioStreamPlayer.new()
    new_player.stream = stream
    new_player.bus = "Music"
Animation

Sprite Animation State Machine

Simple state-based sprite animation using AnimatedSprite2D

extends CharacterBody2D

@onready var sprite = $AnimatedSprite2D

enum State { IDLE, RUN, JUMP, FALL }
var current_state := State.IDLE

func _physics_process(delta):
Animation

Tween UI Effects Collection

Reusable tween effects for punch scale, fade, slide-in, and bounce

extends Node

# Punch scale (e.g., coin pickup, button press)
static func punch_scale(node: Node, strength := 1.3, duration := 0.3):
    var tween = node.create_tween()
    tween.tween_property(node, "scale", Vector2.ONE * strength, duration * 0.4)
    tween.tween_property(node, "scale", Vector2.ONE, duration * 0.6).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_ELASTIC)
Animation

Sprite Flash on Hit

Flash a sprite white briefly when the character takes damage

extends CharacterBody2D

@onready var sprite = $Sprite2D

# Requires a ShaderMaterial on the Sprite2D with a "flash_amount" uniform
# Or use modulate for a simpler approach:

func flash_damage(duration := 0.15, flashes := 3):
AI

Simple Patrol AI

Enemy that walks between patrol points and waits at each one

extends CharacterBody2D

@export var patrol_points: Array[Marker2D] = []
@export var speed := 100.0
@export var wait_time := 1.5

var current_point := 0
var waiting := false
AI

Follow/Chase Player

Enemy that detects and chases the player within a detection radius

extends CharacterBody2D

@export var speed := 120.0
@export var detection_radius := 200.0
@export var stop_distance := 30.0

var player: Node2D = null
AI

State Machine NPC

Finite state machine for NPC behavior: idle, patrol, chase, attack

extends CharacterBody2D

enum State { IDLE, PATROL, CHASE, ATTACK }

var current_state := State.IDLE
var player: Node2D = null
@export var patrol_speed := 80.0
@export var chase_speed := 150.0
Open Guide
AI

Random Wander AI

NPC that picks random nearby positions and wanders between them

extends CharacterBody2D

@export var wander_radius := 150.0
@export var speed := 60.0
@export var idle_time_min := 1.0
@export var idle_time_max := 3.0

var home_position := Vector2.ZERO

Track your progress as you learn

Earn XP, unlock achievements, and level up from Newbie to Legend across 15 guides.

Start Learning