instruction stringlengths 23 114 | output stringlengths 561 1.82k | category stringclasses 19
values | difficulty stringclasses 3
values | godot_version stringclasses 6
values | tags listlengths 2 5 |
|---|---|---|---|---|---|
How do I use the ternary operator and walrus-like patterns in GDScript? | GDScript's conditional expression is `value_if_true if condition else value_if_false`:
```gdscript
var speed := 600.0 if is_sprinting else 300.0
var label := "%d/%d" % [hp, max_hp] if hp > 0 else "KO"
# Chained
var rank := "S" if score > 9000 else "A" if score > 7000 else "B"
# GDScript has no walrus operator (:= in... | gdscript | beginner | 4.x | [
"gdscript",
"syntax",
"expressions"
] |
How do I make a physics-based vehicle or rolling ball controller? | Ball rolling via torque and motor forces:
```gdscript
# rolling_ball.gd
extends RigidBody2D
const MAX_SPEED := 800.0
const ACCEL := 2000.0
func _physics_process(delta: float) -> void:
var input := Input.get_axis("left", "right")
# Cap speed along the ground
if absf(linear_velocity.x) < MAX_SPEED:
apply_centra... | physics | advanced | 4.x | [
"physics",
"vehicle",
"rigidbody"
] |
How do I encrypt save files to prevent tampering? | Encrypted saves via FileAccess:
```gdscript
const SECRET := "your-game-secret-key-2024" # store obfuscated, not plain
func save_encrypted(data: Dictionary) -> void:
var file := FileAccess.open_encrypted_with_pass(
SAVE_PATH, FileAccess.WRITE, SECRET.sha256_text())
file.store_string(JSON.stringify(data))
file.c... | data_save | intermediate | 4.x | [
"save-system",
"encryption",
"security"
] |
How do I implement a simple quest/interaction NPC system? | NPCs with dialogue state, proximity prompt, and signal-driven flow:
```gdscript
# npc.gd
extends Area2D
@export var npc_name := "Elder"
@export var lines: Array[String] = [
"The forest grows dark.",
"Bring me 3 herbs and I'll show the path.",
]
var _talked := false
func _unhandled_input(event: InputEvent) -> void:... | 2d | intermediate | 4.x | [
"2d",
"npc",
"dialogue",
"quests"
] |
How is 3D structured in Godot compared to 2D? | 3D swaps Node2D for Node3D (spatial) hierarchies and Vector2 for Vector3:
```gdscript
# Typical 3D scene:
# Player (CharacterBody3D)
# ├── CollisionShape3D (CapsuleShape3D)
# ├── MeshInstance3D (visual)
# └── Camera3D
# Level (Node3D)
# ├── WorldEnvironment (sky, fog, ambient)
# ├── DirectionalLight3D (sun)
# └── Lev... | 3d | beginner | 4.x | [
"3d",
"fundamentals"
] |
How do I write unit tests for GDScript code? | Popular frameworks: **gdUnit4** (Asset Library / GitHub) and **GUT**. With gdUnit4, a test file:
```gdscript
# res://tests/test_damage_test.gd
class_name TestDamage extends GdUnitTestSuite
func test_take_damage_reduces_health() -> void:
var enemy := auto_free(Enemy.new()) # auto_free cleans up after test
enemy.he... | gdscript | advanced | 4.x | [
"testing",
"gdunit",
"ci"
] |
How do I make the camera follow the player smoothly with limits? | Camera2D as a child of the player, configured for smoothing and bounds:
```gdscript
# Inspector settings on Camera2D:
# position_smoothing_enabled = true
# position_smoothing_speed = 5.0
# limit_left/right/top/bottom = level bounds in pixels
# Code-based look-ahead (camera leads into movement direction):
extends Came... | 2d | beginner | 4.x | [
"2d",
"camera",
"platformer"
] |
How do I write an outline shader for 3D models (inverted hull)? | Inverted hull outline pass:
```glsl
// outline.gdshader — applied to a DUPLICATE mesh child
shader_type spatial;
render_mode unshaded, cull_front;
uniform vec4 outline_color : source_color = vec4(0.0, 0.0, 0.0, 1.0);
uniform float thickness : hint_range(0.0, 0.1) = 0.02;
void vertex() {
VERTEX += NORMAL * thickness... | shaders | intermediate | 4.x | [
"shader",
"outline",
"3d"
] |
How does _get_property_list and _set/_get work for dynamic properties? | Scripts can expose virtual properties that don't exist as real variables — used by editors and for data-driven configs:
```gdscript
var dynamic_data := {}
func _get_property_list() -> Array[Dictionary]:
var props: Array[Dictionary] = []
for key in dynamic_data:
props.append({
"name": key,
"type": typeof(dyn... | gdscript | advanced | 4.x | [
"reflection",
"properties",
"editor"
] |
How do I sync animations with gameplay events (attack frames, footstep sounds)? | Method call tracks and animation signals:
```gdscript
# Method track: in the Animation editor, add a 'Call Method Track',
# key at frame 12 → _on_attack_hit. The engine calls it during playback.
func _on_attack_hit() -> void:
$Hitbox.activate() # exact frame the swing connects
AudioManager.play(&"swing")
... | animation | intermediate | 4.x | [
"animation",
"sync",
"combat"
] |
How do I implement a health bar, damage flash, and death for the player? | Health display driven by signals, damage feedback via modulate:
```gdscript
# player.gd
signal health_changed(current: int, max: int)
signal died
@export var max_health := 5
var health := max_health
func take_damage(amount: int) -> void:
health = maxi(health - amount, 0)
health_changed.emit(health, max_health)
_f... | 2d | beginner | 4.x | [
"2d",
"health",
"ui",
"signals"
] |
How do I build a quest system with objectives and rewards? | Data-driven quests:
```gdscript
# quest.gd
class_name Quest
extends Resource
@export var id: StringName
@export var title: String
@export var description: String
@export var objectives: Array[QuestObjective]
@export var reward_gold := 0
@export var reward_items: Array[StringName]
# quest_objective.gd
class_name Ques... | data_save | advanced | 4.x | [
"quests",
"systems",
"data-driven"
] |
How do I support ultra-wide monitors and unusual resolutions? | Ultra-wide compatibility:
```gdscript
# 1. UI: anchor 'expand' layouts handle any ratio — verify with:
get_window().size = Vector2i(3440, 1440) # test in code? — use window modes in editor
# 2. Camera: clamp visible world to level bounds regardless of ratio:
func setup_camera_limits() -> void:
var cam: Camera2D = ... | export_optimization | intermediate | 4.x | [
"ui",
"resolution",
"camera",
"ultrawide"
] |
How do I create an infinite scrolling background with Parallax2D? | Godot 4.3+ introduced Parallax2D (replacing ParallaxBackground/ParallaxLayer, which still work):
```gdscript
# Scene: Parallax2D (child of your world, NOT the camera)
# └── Sprite2D (your background texture)
# On the Parallax2D node:
# scroll_scale = Vector2(0.2, 0.2) # moves at 20% of camera speed
# repeat_size =... | 2d | beginner | 4.3+ | [
"2d",
"parallax",
"background"
] |
How do I use Animation resources (.tres) shared between scenes? | Animations can live as external shared resources:
```gdscript
# Save an animation standalone:
# In the Animation editor, Animation dropdown → Save As... → res://anims/spin.tres
# Reuse across players:
@onready var anim: AnimationPlayer = $AnimationPlayer
func _ready() -> void:
var shared := load("res://anims/spin.t... | animation | intermediate | 4.x | [
"animation",
"resources",
"reuse"
] |
How do I implement a day-night cycle in 3D? | Rotate the sun + tint the sky + adjust ambient:
```gdscript
# day_night.gd
extends DirectionalLight3D
@export var day_length := 120.0 # seconds per full cycle
var _time := 0.3 # 0..1, 0.25 = noon-ish
@onready var env: Environment = $WorldEnvironment.environment
func _process(delta: float) -> void... | 3d | intermediate | 4.x | [
"3d",
"day-night",
"lighting",
"environment"
] |
How do I show notifications, toasts, and achievement popups? | Queue-based notification system:
```gdscript
# notifications.gd (autoload CanvasLayer)
extends CanvasLayer
var _queue: Array[Dictionary] = []
var _showing := false
func notify(text: String, icon: Texture2D = null, duration := 3.0) -> void:
_queue.append({"text": text, "icon": icon, "duration": duration})
if not _s... | ui | intermediate | 4.x | [
"ui",
"notifications",
"toasts"
] |
How do I make 3D text in the world (labels, signs, damage numbers)? | Label3D renders text in 3D space:
```gdscript
# Floating damage number
func show_damage(pos: Vector3, amount: int, crit := false) -> void:
var label := Label3D.new()
label.text = str(amount)
label.font_size = 48
label.pixel_size = 0.005 # world scale per pixel
label.modulate = Color.RED if crit else Col... | 3d | beginner | 4.x | [
"3d",
"label3d",
"text",
"ui"
] |
How do I define and use bit flags in GDScript? | Bit flags pack boolean states into one int — compact for saves and fast checks:
```gdscript
const CAN_DASH := 1 << 0 # 1
const CAN_SHOOT := 1 << 1 # 2
const CAN_JUMP := 1 << 2 # 4
var abilities := CAN_DASH | CAN_SHOOT # combine with OR
if abilities & CAN_DASH: # test with AND
print("can das... | gdscript | advanced | 4.x | [
"bitflags",
"patterns"
] |
How do I make a TileMapLayer affect navigation for pathfinding enemies? | Wire tiles into the navigation system:
1. TileSet → **Navigation layer** → add element (default layer 0).
2. Per tile: Navigation tab → paint a navigation polygon (or enable 'Merge with default'? — paint the walkable area of the tile as a polygon).
3. The TileMapLayer's nav polygons merge into a navigation region auto... | tilemaps | intermediate | 4.x | [
"tilemap",
"navigation",
"pathfinding"
] |
How do I connect signals in the editor versus in code? | Editor way: select the emitting node → Node dock → Signals tab → double-click the signal → pick the listener node → choose/create the handler method. Godot writes the connection into the .tscn file. Code way:
```gdscript
func _ready() -> void:
button.pressed.connect(_on_button_pressed) # method reference
bu... | signals | beginner | 4.x | [
"signals",
"editor",
"connections"
] |
How do I implement tutorials and onboarding that teach without walls of text? | Contextual tutorial system:
```gdscript
# tutorial_manager.gd (autoload)
var _flags := {} # persists in save
func maybe_show(id: StringName, condition: Callable, popup: PackedScene) -> void:
if _flags.has(id) or not condition.call():
return
_flags[id] = true
var inst := popup.instantiate()
add_child(inst)
in... | advanced | intermediate | 4.x | [
"tutorial",
"onboarding",
"design"
] |
How do I declare variables in GDScript? | Use `var` for mutable variables and `const` for constants. Type inference with `:=` is preferred:
```gdscript
var speed := 300.0 # inferred float
var health: int = 100 # explicit type
var name := "Player" # inferred String
var items: Array[String] = [] # typed array
const GRAVITY := 980.0 ... | gdscript | beginner | 4.x | [
"gdscript",
"variables",
"typing"
] |
How do I set up and use custom resources in GDScript? | Custom Resources are data containers saved as .tres files — perfect for items, abilities, level metadata:
```gdscript
# item_data.gd
class_name ItemData
extends Resource
@export var id: StringName
@export var display_name: String
@export var icon: Texture2D
@export var stackable := true
@export var max_stack := 99
@e... | gdscript | intermediate | 4.x | [
"resources",
"data",
"architecture"
] |
How do I write a 3D spatial shader with custom lighting? | Spatial shader structure:
```glsl
shader_type spatial;
render_mode blend_mix, depth_draw_always, cull_back, diffuse_burley, specular_schlick_ggx;
uniform vec4 base_color : source_color = vec4(0.8, 0.2, 0.2, 1.0);
uniform float metal : hint_range(0.0, 1.0) = 0.0;
uniform float rough : hint_range(0.0, 1.0) = 0.5;
unifo... | shaders | intermediate | 4.x | [
"shader",
"spatial",
"3d"
] |
What rendering methods does Godot 4 offer and which should I choose? | Godot 4 offers three renderers, chosen per project in Project Settings → Rendering → Renderer, or when creating the project: **Forward+** (Vulkan) is the default desktop renderer with the full feature set — clustered lighting, SDFGI/GI, SSAO, SDF shadows, volumetric fog. **Mobile** is a scaled-down Vulkan renderer tune... | basics | beginner | 4.x | [
"rendering",
"graphics",
"project-setup"
] |
How do I localize text in Godot? | Godot's localization uses CSV or PO translation files. Workflow: Project Settings → Localization → Add → create `translations.csv` with header `keys,en,de,fr`, rows like `MENU_START,Start,Starten,Démarrer`. Import the CSV (auto-detected) and either (1) set Project Settings → Internationalization → Locale → Translations... | gdscript | intermediate | 4.x | [
"localization",
"ui",
"workflow"
] |
How do I implement tool tips for skills with cooldown display? | Cooldown-aware tooltips:
```gdscript
# skill_button.gd
extends Button
@export var skill_id: StringName
var _cooldown_left := 0.0
func _ready() -> void:
Events.skill_used.connect(_on_skill_used)
func _process(delta: float) -> void:
if _cooldown_left > 0:
_cooldown_left = maxf(_cooldown_left - delta, 0.0)
%Cool... | misc | intermediate | 4.x | [
"ui",
"tooltips",
"cooldowns"
] |
How do I make animated cutscenes with AnimationPlayer driving the scene? | AnimationPlayer as cutscene sequencer:
1. Create an AnimationPlayer at the cutscene root, new animation 'intro' (length = scene duration, e.g. 15s).
2. Keyframe: camera position/rotation (Camera3D tracks), character positions (path them via animated Node3D targets), dialogue UI visibility, lights, audio tracks (voice/... | animation | intermediate | 4.x | [
"animation",
"cutscene",
"sequencing"
] |
How do I add credits that auto-update from a data file? | Data-driven credits:
```gdscript
# credits.json
# {
# "sections": [
# {"title": "Programming", "people": ["Alex Chen", "Sam Okafor"]},
# {"title": "Art", "people": ["Mira Volkov"]},
# {"title": "Special Thanks", "people": ["The Godot Community"]}
# ]
# }
# credits.gd
func build() -> void:
var data :=... | misc | beginner | 4.x | [
"credits",
"legal",
"workflow"
] |
How do I implement waypoints, patrol paths, and moving 3D platforms? | Path3D + PathFollow3D is the built-in spline-follow system:
```
MovingPlatform (AnimatableBody3D, sync_to_physics = true)
└── Path3D (curve points authored in editor)
└── PathFollow3D (progress_ratio 0..1)
└── MeshInstance3D (the platform mesh)
```
```gdscript
# Move along the path, ping-pong
@onready var... | 3d | intermediate | 4.x | [
"3d",
"paths",
"platforms",
"movement"
] |
How do I implement a screenshot + GIF capture system for marketing? | Capture tooling:
```gdscript
# capture_tool.gd (debug-only autoload)
extends Node
var _recording := false
var _frames: Array[Image] = []
var _capture_fps := 30.0
var _accum := 0.0
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("debug_screenshot"):
take_screenshot()
elif event.is_act... | advanced | intermediate | 4.x | [
"marketing",
"capture",
"tooling"
] |
How do for and while loops work in GDScript? | GDScript loops:
```gdscript
# Iterate a range (0..9)
for i in range(10):
print(i)
# Range with step
for i in range(0, 100, 5):
print(i)
# Iterate arrays, dictionaries, strings
for item in inventory:
print(item)
for key in scores: # dictionary iterates keys
print(key, scores[key])
for k: String in scor... | gdscript | beginner | 4.x | [
"gdscript",
"loops",
"control-flow"
] |
How do I use _integrate_forces for custom physics behavior? | `_integrate_forces(state)` is RigidBody's direct line to the physics server — per-step state access:
```gdscript
extends RigidBody2D
func _integrate_forces(state: PhysicsDirectBodyState2D) -> void:
# Read contacts precisely
for i in state.get_contact_count():
var normal := state.get_contact_local_normal(i)
if n... | physics | advanced | 4.x | [
"physics",
"integrate-forces",
"rigidbody"
] |
How do I light a 3D scene well in Godot 4? | Light types and their roles:
```gdscript
# DirectionalLight3D — sun/moon. ONE per scene typically.
# rotation: ~-45° for pleasing shadows; shadow_max_distance 100–200m
# OmniLight3D — point light (lamps, torches). range in meters.
# SpotLight3D — cone (flashlights, headlights). angle + range.
# Flicker for torches:
... | 3d | intermediate | 4.x | [
"3d",
"lighting",
"shadows",
"environment"
] |
How do I handle connection lifecycle (join, leave, late-join, disconnect)? | Connection flow management:
```gdscript
# network_manager.gd (autoload)
func _ready() -> void:
multiplayer.peer_connected.connect(_on_peer_connected)
multiplayer.peer_disconnected.connect(_on_peer_disconnected)
multiplayer.connected_to_server.connect(_on_connected_ok)
multiplayer.connection_failed.connect(_on_conn... | advanced | intermediate | 4.x | [
"multiplayer",
"lifecycle",
"connections"
] |
What is an Autoload (singleton) and when should I use one? | An Autoload is a node/script registered in Project Settings → Globals → Autoload that Godot instances automatically at startup and keeps alive across all scene changes, accessible globally by its name. Use autoloads for truly global systems: settings persistence, an audio manager, a quest/state manager, scene transitio... | basics | beginner | 4.x | [
"autoload",
"singleton",
"architecture"
] |
How do I implement achievements with Steam and local fallback? | Achievement abstraction:
```gdscript
# achievements.gd (autoload)
const DEFS := {
&"first_kill": {"name": "First Blood", "desc": "Defeat your first enemy"},
&"speedrun": {"name": "Speed Demon", "desc": "Finish under 20 minutes"},
}
var _unlocked: Dictionary = {}
func _ready() -> void:
_load_local()
func unlock(i... | advanced | intermediate | 4.x | [
"achievements",
"steam",
"meta"
] |
How do I handle export presets per platform with feature tags? | Feature-based builds:
```gdscript
# Built-in feature tags:
OS.has_feature("windows") # also linux, macos, android, ios, web
OS.has_feature("desktop") # any desktop
OS.has_feature("mobile") # android or ios
OS.has_feature("web")
OS.has_feature("debug") # debug build (editor-run or debug export)
OS.has_featur... | export_optimization | intermediate | 4.x | [
"export",
"features",
"variants"
] |
How do typed arrays work in Godot 4 and why use them? | Typed arrays constrain element type at declaration: `var ids: Array[int] = []`, `var scenes: Array[PackedScene] = []`. Benefits: (1) the editor Inspector renders typed arrays with proper per-element editors (pick a scene, not arbitrary values); (2) type errors surface immediately instead of deep in gameplay; (3) some A... | gdscript | intermediate | 4.x | [
"gdscript",
"arrays",
"typing"
] |
How do I handle time, cooldowns, and timers correctly in GDScript? | Three tools, three use cases:
```gdscript
# 1. SceneTreeTimer — fire-and-forget delays
await get_tree().create_timer(0.5).timeout
# 2. Timer NODE — repeating, pausable, editor-tunable
@onready var shoot_timer: Timer = $ShootTimer
func _ready() -> void:
shoot_timer.timeout.connect(_shoot)
shoot_timer.start(2.0) ... | gdscript | intermediate | 4.x | [
"timers",
"time",
"cooldowns"
] |
How does CharacterBody2D.move_and_slide() actually work? | `move_and_slide()` moves the body along its `velocity`, colliding and SLIDING along surfaces, and updates state flags you query afterward:
```gdscript
func _physics_process(delta: float) -> void:
velocity.x = input_dir * SPEED
velocity.y += gravity * delta
move_and_slide()
# Post-move inspection:
if is_on_floor(... | 2d | intermediate | 4.x | [
"2d",
"characterbody",
"physics"
] |
How do I create an EditorPlugin in Godot 4? | EditorPlugins extend the editor itself: custom docks, buttons, inspectors, importers:
```gdscript
# addons/my_plugin/plugin.cfg
[plugin]
name="My Plugin"
version="1.0"
script="plugin.gd"
# addons/my_plugin/plugin.gd
@tool
extends EditorPlugin
func _enter_tree() -> void:
add_custom_type("SpinningCube", "Node3D", pre... | gdscript | advanced | 4.x | [
"editor-plugins",
"tool-scripts",
"addons"
] |
How do I implement 3D camera modes (first person, third person, shoulder)? | Camera rig hierarchy supporting all modes:
```
Player (CharacterBody3D)
├── Head (Node3D — pitch + eye height)
│ └── Camera3D (first-person position)
└── CameraRig (Node3D — yaw)
└── SpringArm3D
└── ShoulderCam (Camera3D — third person)
```
```gdscript
enum CamMode { FIRST_PERSON, SHOULDER }
var mode :=... | 3d | intermediate | 4.x | [
"3d",
"camera",
"modes"
] |
How do I implement a minimap or in-world marker for objectives? | Off-screen indicator math + minimap via SubViewport or simple icons:
```gdscript
# Off-screen objective arrow (attached to player's UI)
extends Control
@export var target_path: NodePath
var target: Node2D
func _process(_d: float) -> void:
if not is_instance_valid(target): return
var cam := get_viewport().get_camer... | 2d | intermediate | 4.x | [
"2d",
"ui",
"minimap",
"markers"
] |
How do I implement coroutines that can be cancelled mid-await? | Awaited coroutines can't be cancelled directly, but you can structure cancellation:
```gdscript
var _channel_seq := 0
func play_channel_change(new_channel: int) -> void:
_channel_seq += 1
var my_seq := _channel_seq
await _fade_out(0.2)
if my_seq != _channel_seq: # superseded — abort
return
_switch_to(new_... | gdscript | advanced | 4.x | [
"coroutines",
"await",
"patterns"
] |
How do I implement a rope/bridge with Verlet physics in 2D? | Verlet rope simulation:
```gdscript
# rope.gd
extends Node2D
const SEGMENTS := 20
const SEG_LEN := 12.0
const GRAVITY := 500.0
const ITERATIONS := 4
var points: Array[Dictionary] = [] # {pos, prev}
func _ready() -> void:
for i in SEGMENTS + 1:
var p := Vector2(i * SEG_LEN, 0)
points.append({"pos": p, "prev":... | 2d | advanced | 4.x | [
"verlet",
"rope",
"physics"
] |
What is class_name in GDScript and when should I register a class? | `class_name Foo` registers your script as a global named class, reachable everywhere without preload, and visible in the editor's 'Create New Node' dialog and docs:
```gdscript
class_name HealthComponent
extends Node
# Anywhere else in the project, with zero imports:
var hp := HealthComponent.new()
```
Register when... | gdscript | beginner | 4.x | [
"gdscript",
"class-name",
"oop"
] |
How does the audio bus system work in Godot? | Buses route audio: every player sends to a bus → buses chain to Master:
```
Audio panel (bottom dock):
Master ─┬─ Music
├─ SFX
└─ UI
```
Setup: add buses in the Audio dock (Music, SFX, UI), assign players via the `bus` property, then control whole categories at once:
```gdscript
# Volume slider for t... | audio | beginner | 4.x | [
"audio",
"buses",
"mixing"
] |
Why is my RigidBody2D not moving or moving erratically? | RigidBody behavior fixes:
**Not moving**: (1) you set `position` directly — RigidBody ignores it (physics owns the transform); use `apply_impulse`/`apply_force`/`linear_velocity`; (2) `freeze = true` is on; (3) gravity_scale = 0 and no forces applied; (4) it's sleeping — `can_sleep = false` or wake it.
**Erratic/jitt... | troubleshooting | intermediate | 4.x | [
"rigidbody",
"physics",
"stability"
] |
How do I implement day/night or ambient tinting across a whole level? | Full-screen tint via CanvasModulate — one node tints EVERYTHING under its canvas:
```gdscript
# day_night.gd (autoload or level child)
extends CanvasModulate
const DAY_COLOR := Color(1, 1, 1)
const NIGHT_COLOR := Color(0.25, 0.3, 0.55)
func _ready() -> void:
start_cycle(60.0) # full day-night cycle per 60s
func ... | 2d | intermediate | 4.x | [
"2d",
"lighting",
"atmosphere"
] |
How do I export to Web/HTML5? | Web export setup:
1. Export preset 'Web': use the **Compatibility** renderer (WebGL2 — Forward+/Mobile don't run on web).
2. Key preset options: 'Experimental Virtual Keyboard' (for LineEdit on mobile web), progressive web app settings, threads option (SingleThreaded by default — SharedArrayBuffer requires COOP/COEP h... | export_optimization | intermediate | 4.x | [
"export",
"web",
"html5"
] |
Why do my exported variables show in the editor but reset at runtime? | Export value confusion — the usual suspects:
1. **Script default changed after scene saved**: scenes store their OWN copy of exported values — changing the script's default doesn't update saved scenes. Fix: change values in the Inspector per scene, or right-click the property in Inspector → 'Set to default'? Actually:... | troubleshooting | intermediate | 4.x | [
"exports",
"resources",
"gotchas"
] |
Why is my pixel art blurry or has wrong colors? | Pixel-art rendering fixes:
1. **Blurry**: texture filter is linear. Fix: import setting 'Filter' → Nearest per texture, or project-wide default: Project Settings → Rendering → Textures → Canvas Textures → Default Texture Filter → Nearest.
2. **Wrong colors**: color management — 2D canvas in Godot 4 is sRGB; texture im... | troubleshooting | beginner | 4.x | [
"pixel-art",
"textures",
"rendering"
] |
Why do my tweens not play or complete? | Tween failure modes:
1. **Bound node freed**: tweens created via `node.create_tween()` die with the node — if the node frees mid-tween, it stops silently. Fix: create from a longer-lived node for cross-object animations.
2. **Paused tree**: tweens pause with the tree (default `TweenPauseMode.BOUND`). For pause-immune ... | troubleshooting | beginner | 4.x | [
"tween",
"animation",
"debugging"
] |
How do I implement screen transition effects between rooms or scenes? | Reusable transition autoload with a CanvasLayer fade:
```gdscript
# autoload/transition.gd
extends CanvasLayer
const FADE_TIME := 0.4
@onready var rect: ColorRect = $ColorRect
func _ready() -> void:
layer = 100
process_mode = Node.PROCESS_MODE_ALWAYS
rect.modulate.a = 0.0
func change_scene(path: String) -> void:... | 2d | intermediate | 4.x | [
"2d",
"transitions",
"scenes",
"autoload"
] |
How do I create and use constants and enums in GDScript? | Constants are compile-time immutable values; enums are named integer sets:
```gdscript
const MAX_HP := 100
const GRAVITY := Vector2(0, 980)
const ENEMY_SCENE := preload("res://enemy.tscn") # preload IS a constant
enum Direction { LEFT, RIGHT, UP, DOWN } # 0,1,2,3
enum { IDLE, RUN, ATTACK } # anonym... | gdscript | beginner | 4.x | [
"gdscript",
"constants",
"enums"
] |
How do I implement a leaderboard (local and online)? | Local scores + online via HTTP:
```gdscript
# leaderboard.gd (autoload)
const API_URL := "https://your-api.example.com/scores"
func submit_score(name: String, score: int) -> void:
# Local always
var local := load_local()
local.append({"name": name, "score": score, "date": today()})
local.sort_custom(func(a, b): r... | data_save | intermediate | 4.x | [
"leaderboard",
"http",
"persistence"
] |
How do I implement one-way moving platforms that also work from below? | Combining one-way collision with AnimatableBody2D:
```gdscript
# Platform scene: AnimatableBody2D + CollisionShape2D (one_way_collision = true)
extends AnimatableBody2D
@export var travel := Vector2(0, -150)
@export var wait_time := 1.0
func _ready() -> void:
sync_to_physics = true
_loop()
func _loop() -> void:
... | physics | intermediate | 4.x | [
"physics",
"platforms",
"one-way"
] |
How do I implement camera shake and hit-stop for game feel? | Screen shake via offset noise, hit-stop via timescale or physics freeze:
```gdscript
# shake_camera.gd — child Camera2D with position_smoothing on parent
var shake_amount := 0.0
func shake(strength: float) -> void:
shake_amount = maxf(shake_amount, strength)
func _process(delta: float) -> void:
if shake_amount > 0... | 2d | intermediate | 4.x | [
"2d",
"camera",
"game-feel",
"juice"
] |
How do I build a data-driven dialogue/interaction system with Resources? | Resource-graph interactions:
```gdscript
# interaction.gd
class_name Interaction
extends Resource
@export var condition_flag: StringName # GameState flag required
@export var lines: Array[String]
@export var choices: Array[InteractionChoice]
@export var actions: Array[GameAction] # effects on compl... | advanced | advanced | 4.x | [
"resources",
"dialogue",
"data-driven"
] |
How do I use the AnimationTree state machine for 3D locomotion? | AnimationTree blends walk/run/idle by speed — no foot sliding:
```
AnimationTree (tree_root = StateMachine)
├── Idle (Animation node: idle clip, blend time 0.2)
├── Walk (Animation: walk clip)
├── Run (Animation: run clip)
└── Travel between them with conditions
```
```gdscript
@onready var tree: AnimationTree... | 3d | advanced | 4.x | [
"3d",
"animation-tree",
"locomotion"
] |
How do I make transparent or alpha-blended materials in 3D? | Transparency modes in StandardMaterial3D → Transparency dropdown:
```
Disabled — opaque (fastest)
Alpha — true transparency (glass, ghosts). Sorting artifacts possible
Alpha Scissor — hard cutoff at threshold (foliage, fences — NO sorting issues)
Alpha Depth Pre-pass — alpha edges with opaque interior (char... | 3d | intermediate | 4.x | [
"3d",
"materials",
"transparency"
] |
How do I declare and emit custom signals in GDScript 2.0? | Declare with the `signal` keyword, emit with `.emit()`:
```gdscript
signal died # no arguments
signal health_changed(current: int, max: int) # typed arguments
signal item_picked(item: Node2D, slot: int)
func take_damage(amount: int) -> void:
health_changed.emit(health, max_health)
... | signals | beginner | 4.x | [
"signals",
"gdscript"
] |
How do I create a scene purely from code (no .tscn file)? | Full programmatic construction — useful for procedural UI, generated levels, or tests:
```gdscript
func build_pause_menu() -> Control:
var layer := CanvasLayer.new()
layer.layer = 100
layer.process_mode = Node.PROCESS_MODE_ALWAYS
var panel := PanelContainer.new()
panel.set_anchors_preset(Control.PRESET_CENTER)
... | nodes_scenes | intermediate | 4.x | [
"scenes",
"code-generation",
"ui"
] |
What is the difference between res:// and user:// paths in Godot? | `res://` ('resource') points to the project root and is read-only at runtime — it is where your scenes, scripts, textures, and audio live. When the game is exported, everything under `res://` is packed into a PCK archive, so you cannot write files there at runtime. `user://` points to a writable per-user directory (e.g... | basics | beginner | 4.x | [
"filesystem",
"paths"
] |
How do I implement resource management for a large project (memory budgets)? | Memory discipline for big games:
```gdscript
# 1. Budget monitoring:
func report_memory() -> void:
print("Static: ", OS.get_static_memory_usage() / 1048576.0, " MB")
print("Textures: ", RenderingServer.get_rendering_info(
RenderingServer.RENDERING_INFO_TEXTURE_MEM_USED) / 1048576.0, " MB")
print("Meshes: ", Rende... | advanced | advanced | 4.x | [
"memory",
"resources",
"optimization"
] |
How do I implement enemy wave spawning with budgets? | Wave director:
```gdscript
# wave_director.gd
extends Node2D
signal wave_completed(wave: int)
signal all_waves_completed
@export var waves: Array[Dictionary] = []
# waves: [{"budget": 100, "types": [{"id": &"grunt", "cost": 10}, {"id": &"brute", "cost": 40}]}]
var _alive := 0
var _current_wave := 0
func start() ->... | misc | intermediate | 4.x | [
"waves",
"spawning",
"design"
] |
Why does my game work in the editor but fail in exported builds (missing resources)? | Export-missing resources — causes:
1. **Non-imported file types**: text/JSON/CSV files inside res:// are NOT exported by default unless the import system knows them. Fix: export preset → Resources → 'Export Mode' → 'Export all resources in the project', or add explicit filters (*.json, *.csv).
2. **Runtime path constr... | troubleshooting | intermediate | 4.x | [
"export",
"resources",
"web"
] |
How do I implement a free-fly debug camera? | Debug fly camera:
```gdscript
# fly_camera.gd — toggle over the gameplay camera
extends Node3D
var _enabled := false
var _speed := 8.0
var _saved_cam: Camera3D
func _ready() -> void:
var cam := Camera3D.new()
cam.name = "FlyCamera"
add_child(cam)
func _unhandled_input(event: InputEvent) -> void:
if event.is_act... | advanced | intermediate | 4.x | [
"debug",
"camera",
"tooling"
] |
How do I store large amounts of game data — spreadsheets, CSV, or custom Resources? | Data-pipeline options by scale:
```gdscript
# 1. Custom Resources — small-medium, editor-editable
# items/*.tres with an ItemData script — best DX for < ~200 entries
# 2. JSON — interop, modding-friendly
var file := FileAccess.open("res://data/items.json", FileAccess.READ)
var items: Dictionary = JSON.parse_string(fi... | data_save | intermediate | 4.x | [
"data",
"csv",
"resources",
"pipeline"
] |
How do I detect and handle the first frame vs later frames (_enter_tree ordering pitfalls)? | Tree order: parent `_enter_tree` → children `_enter_tree` (depth-first) → children `_ready` (leaves first) → parent `_ready`. Consequences:
```gdscript
# WRONG in _ready: parent isn't ready yet when YOUR _ready runs (children ready first)
func _ready() -> void:
get_parent().setup(self) # parent's _ready may not h... | gdscript | advanced | 4.x | [
"lifecycle",
"tree-order",
"pitfalls"
] |
How do I read gamepad input including axes, deadzones, and vibration? | Controller input via the same action system plus device APIs:
```gdscript
# Axes: -1..1 with deadzone applied via actions in Input Map
var steer := Input.get_axis("steer_left", "steer_right")
# Raw axis reading (deadzone manual):
var raw := Input.get_joy_axis(0, JOY_AXIS_LEFT_X)
if absf(raw) > 0.2:
apply_steer(raw)
... | input | intermediate | 4.x | [
"input",
"gamepad",
"controllers"
] |
How do I make objects float or sink in water with 2D physics? | Buoyancy via per-body forces in the water Area2D:
```gdscript
# water_zone.gd
extends Area2D
const DENSITY := 1.6
const DRAG := 2.0
func _physics_process(delta: float) -> void:
for body in get_overlapping_bodies():
if body is RigidBody2D:
# Submersion depth fraction (approximate by center position)
var dept... | physics | advanced | 4.x | [
"physics",
"buoyancy",
"water"
] |
How do I set up 3D shadows well (quality vs performance)? | Shadow tuning lives on the light + project settings:
```gdscript
# DirectionalLight3D (sun) — the expensive one
light.shadow_enabled = true
light.directional_shadow_mode = Light3D.SHADOW_PARALLEL_4_SPLITS # quality
light.directional_shadow_max_distance = 100.0 # meters — lower = sharper
light.shadow_bias = 0.03 ... | 3d | intermediate | 4.x | [
"3d",
"shadows",
"performance",
"lighting"
] |
How do I optimize a 3D scene that runs slow — profiling checklist? | Systematic 3D performance triage:
1. **Measure first**: Debugger → Monitors (FPS, draw calls, VRAM); use the built-in profiler, and `--profiling`? — plus external renders? Keep it in-engine: Profiler tab records per-function; Rendering → 'Frame time breakdown' via `Performance.get_monitor(PERF_RENDER_...)`.
2. **Draw... | 3d | advanced | 4.x | [
"3d",
"performance",
"profiling",
"optimization"
] |
How do I do destructible/interactive terrain (digging, mining) with tilemaps? | Pixel-style digging via runtime cell editing:
```gdscript
# Mining: remove a cell + spawn drop
func mine_at(world_pos: Vector2) -> void:
var cell := ground.local_to_map(ground.to_local(world_pos))
var data := ground.get_cell_tile_data(cell)
if data == null: return
if data.get_custom_data("mineable"):
ground.eras... | tilemaps | intermediate | 4.x | [
"tilemap",
"destruction",
"mining"
] |
How does Godot 4 multiplayer networking work (high-level multiplayer API)? | Godot's high-level multiplayer wraps networking into RPCs on the scene tree:
```gdscript
# Host
func host_game(port := 7777) -> Error:
var peer := ENetMultiplayerPeer.new()
var err := peer.create_server(port, 8) # max 8 clients
if err != OK:
return err
multiplayer.multiplayer_peer = peer
multiplayer.peer_conn... | advanced | intermediate | 4.x | [
"multiplayer",
"networking",
"rpc"
] |
How do I implement checkpoints and respawn? | Checkpoint flow with save integration:
```gdscript
# checkpoint.gd
extends Area2D
@export var checkpoint_id := 0
func _on_body_entered(body: Node2D) -> void:
if not body.is_in_group("player"):
return
if Game.current_checkpoint >= checkpoint_id:
return # older checkpoint
Game.current_checkpoint = checkpoint_... | data_save | intermediate | 4.x | [
"checkpoints",
"respawn",
"save-system"
] |
How do I implement orbiting camera for inspection screens (item viewers)? | Turntable camera with input:
```gdscript
# item_inspector.gd
extends Node3D
@onready var pivot: Node3D = $Pivot # item parent, rotates
@onready var cam: Camera3D = $Camera3D
var _rotating := false
var _last_pos := Vector2.ZERO
func _unhandled_input(event: InputEvent) -> void:
if event is InputEventMouseButton... | 3d | intermediate | 4.x | [
"3d",
"camera",
"ui",
"inspection"
] |
Why does my Y-sorted scene render in the wrong order? | Y-sort diagnosis:
1. **Not siblings**: Y-sort only orders DIRECT children of the y_sort_enabled node. Nested scenes need y_sort_enabled on EVERY level that orders.
2. **Origin mismatch**: sort compares node ORIGIN y — a sprite whose visual feet are 30px below its origin sorts wrong. Fix: position the origin at feet (o... | troubleshooting | intermediate | 4.x | [
"y-sort",
"rendering",
"2d"
] |
What is the difference between _ready(), _process(), and _physics_process()? | `_ready()` is called exactly once, when the node and ALL its children have entered the scene tree — use it for setup: caching node references, connecting signals, initializing state. `_process(delta)` runs every rendered frame — use it for non-physics logic: reading input, updating UI, timers, animations of non-physics... | basics | beginner | 4.x | [
"lifecycle",
"gdscript",
"fundamentals"
] |
How do I run and test my game in Godot? | Press F5 (or the ▶ button) to run the main scene of the project. If no main scene is set, Godot asks you to choose one — pick your entry scene (e.g. `main.tscn`) or set it later in Project Settings → Application → Run → Main Scene. F6 runs only the currently open scene, which is great for testing a single component in ... | basics | beginner | 4.x | [
"editor",
"debugging",
"workflow"
] |
How do I implement host migration or reconnect systems? | Reconnection design:
```gdscript
# Simple reconnect (same session):
var _my_peer_id := 0
func _ready() -> void:
_my_peer_id = multiplayer.get_unique_id()
func attempt_reconnect(ip: String, port: int) -> void:
UI.show_reconnecting()
for attempt in 5:
var err := join_game(ip, port)
if err == OK:
# Server rec... | advanced | advanced | 4.x | [
"multiplayer",
"reconnect",
"sessions"
] |
How do I implement hit reactions and hitboxes in 3D combat? | Hitbox/hurtbox Area3D pattern mirroring 2D:
```gdscript
# hurtbox.gd — on every damageable character
extends Area3D
signal damaged(amount: int, from: Vector3)
# hitbox.gd — on weapons/attacks
extends Area3D
@export var damage := 10
@export var active_frames := 0.15
func activate() -> void: # called by the atta... | 3d | intermediate | 4.x | [
"3d",
"combat",
"hitbox",
"animation"
] |
How do Control nodes and anchors work for responsive UI? | Controls position via anchors relative to their parent rect:
```
Anchor presets (Inspector → Layout):
Full Rect — fills parent (HUD roots, panels)
Center — centered with own size
Top Wide — banner across the top
Bottom Wide — footer
```
```gdscript
# Code equivalents:
label.set_a... | ui | beginner | 4.x | [
"ui",
"anchors",
"control"
] |
How do I instantiate a scene from code in Godot 4? | Load the PackedScene and call `instantiate()`, then add it to the tree:
```gdscript
const BULLET := preload("res://scenes/bullet.tscn")
func shoot() -> void:
var bullet := BULLET.instantiate() as Node2D
bullet.global_position = muzzle.global_position
bullet.rotation = global_rotation
get_parent().add_child(bullet... | nodes_scenes | beginner | 4.x | [
"instancing",
"scenes"
] |
What is the structure of a Godot 4 shader file (.gdshader)? | Godot shading language structure:
```glsl
shader_type canvas_item; // or spatial, particles, sky, fog
// Uniforms — settable from GDScript via material.set_shader_parameter
uniform vec4 tint : source_color = vec4(1.0);
uniform float strength : hint_range(0.0, 1.0) = 0.5;
uniform sampler2D noise_tex;
void vertex() ... | shaders | beginner | 4.x | [
"shader",
"gdshader",
"fundamentals"
] |
How do I use await/async patterns for game logic (timelines, combos)? | Coroutine game patterns:
```gdscript
# Combo system: chains of timed inputs
func _try_combo() -> void:
combo_window = true
await get_tree().create_timer(0.4).timeout
combo_window = false
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("attack"):
if combo_window and _last_combo < MAX... | advanced | intermediate | 4.x | [
"coroutines",
"await",
"patterns"
] |
How do I use AudioStreamSpectrumAnalyzer for music visualizers? | Spectrum analysis on any playing bus:
```gdscript
func _ready() -> void:
var effect := AudioEffectSpectrumAnalyzer.new()
effect.buffer_length = 2.0
effect.fft_size = AudioEffectSpectrumAnalyzer.FFT_SIZE_2048
AudioServer.add_bus_effect(AudioServer.get_bus_index("Music"), effect)
func _process(_d: float) -> void:
... | audio | advanced | 4.x | [
"audio",
"spectrum",
"visualizer",
"rhythm"
] |
How do I make UI scale correctly across resolutions? | Stretch settings + responsive containers:
```
Project Settings → Display → Window:
Viewport: 1920x1080 (design resolution)
Stretch Mode: canvas_items — UI scales with window
Stretch Aspect: expand — use extra space (no letterbox)
```
Design rules: (1) anchor-based layouts (Full Rect, Center, Wide ... | ui | intermediate | 4.x | [
"ui",
"resolution",
"responsive",
"stretch"
] |
How do I quit the game from code in Godot? | Call `get_tree().quit()` to exit immediately. To quit with a specific exit code (useful for CI testing): `get_tree().quit(1)`. To defer until the current frame finishes processing (safer mid-physics): `get_tree().quit.call_deferred()`. A common pattern for a Quit button:
```gdscript
func _on_quit_pressed() -> void:
g... | basics | beginner | 4.x | [
"scenes",
"workflow"
] |
How do node paths work and how do I reference other nodes safely? | Three reference styles, in increasing robustness:
```gdscript
# 1. $ shorthand (node path relative to current node)
@onready var sprite := $Sprite2D
@onready var bar := $UI/HealthBar # child 'UI' -> child 'HealthBar'
# 2. get_node with absolute path (avoid — brittle)
var player := get_node("/root/Level/Player")
... | gdscript | beginner | 4.x | [
"nodes",
"nodepath",
"architecture"
] |
How do I make a shader for grass wind sway in 3D? | Vertex-displacement wind (the MultiMesh grass classic):
```glsl
shader_type spatial;
render_mode cull_disabled;
uniform sampler2D wind_noise;
uniform float sway_strength = 0.15;
uniform float sway_speed = 1.5;
void vertex() {
// Only bend the TOP of the blade (UV.y = 1 at top)
float bend_weight = UV.y;
// Spati... | shaders | advanced | 4.x | [
"shader",
"wind",
"vegetation",
"vertex"
] |
How does the AnimationTree work with blend spaces? | AnimationTree = graph of blending nodes over your animations:
```
AnimationTree
└── tree_root: BlendSpace2D "Locomotion"
├── x-axis: speed (0..1), y-axis: lateral movement (-1..1)
├── points: idle(0,0), walk(0.5,0), run(1,0), strafe_l(0.5,-1)...
└── blends automatically between nearest points
```
```gdscr... | animation | advanced | 4.x | [
"animation-tree",
"blending"
] |
How do I implement an AoE damage spell with visual ring feedback? | Complete area-effect pattern:
```gdscript
# aoe_blast.gd
extends Node2D
const DAMAGE := 25.0
const RADIUS := 120.0
func cast() -> void:
# Visual: expanding ring
$Ring.scale = Vector2.ONE * 0.1
$Ring.modulate.a = 1.0
var tw := create_tween().set_parallel()
tw.tween_property($Ring, "scale", Vector2.ONE * (RADIUS ... | physics | intermediate | 4.x | [
"physics",
"aoe",
"combat",
"spells"
] |
How do I sync animations and cosmetic state without bandwidth waste? | Bandwidth-tiered synchronization:
```gdscript
# Tier 1: critical state — reliable, on change only
@rpc("authority", "call_remote", "reliable")
func set_health(new_health: int) -> void:
health = new_health
health_bar.update(health)
# Tier 2: movement — unreliable (next packet supersedes), 15Hz not 60Hz
func _ready()... | advanced | advanced | 4.x | [
"multiplayer",
"bandwidth",
"optimization"
] |
How does Godot's scene tree tscn instancing keep references between scenes (owner, editable children)? | When scene A instances scene B, B's nodes belong to B's file — A's scripts can't freely reference B's internals. The `owner` property marks which file each node saves into (root of every scene is its own owner). 'Editable Children' (right-click instance → Editable Children) exposes B's nodes so you can override propert... | gdscript | intermediate | 4.x | [
"scenes",
"instancing",
"owner"
] |
How do I make a level select or room-based structure with tilemap scenes as rooms? | Room-per-scene architecture for metroidvania-style games:
```
rooms/
room_forest_01.tscn (root Node2D, contains TileMapLayers, spawns)
room_forest_02.tscn
room_cave_01.tscn
```
```gdscript
# room_manager.gd — owns loading/unloading as the player crosses exits
var _current: Node2D
func load_room(path: String... | tilemaps | advanced | 4.x | [
"tilemap",
"rooms",
"architecture"
] |
How do I detect and respond to RigidBody collisions (contact monitoring)? | RigidBody2D contact signals need enabling:
```gdscript
extends RigidBody2D
func _ready() -> void:
contact_monitor = true # REQUIRED for body_entered on rigid bodies
max_contacts_reported = 8 # how many simultaneous contacts to track
body_entered.connect(_on_body_entered)
func _on_body_entered(bod... | physics | intermediate | 4.x | [
"physics",
"collision",
"signals",
"rigidbody"
] |
Godot GameDev Instruct 503
A curated instruction-following dataset for fine-tuning LLMs on game development with the Godot Engine 4.x. Every example is a question–answer pair covering real, practical Godot development knowledge — from "what is a Node" through server-authoritative multiplayer, custom shaders, and shipping to Steam.
Columns
| Column | Type | Description |
|---|---|---|
instruction |
string | The question or task (typically "How do I …?" or "What is the difference between …?") |
output |
string | A complete answer: explanation + idiomatic GDScript code where relevant |
category |
string | Topic area (19 categories, see below) |
difficulty |
string | beginner (157), intermediate (230), or advanced (116) |
godot_version |
string | Version sensitivity: 4.x (default) or a minimum version like 4.3+ |
tags |
list[string] | Free-form topical keywords for filtering |
Coverage by category
| Category | Count | Category | Count | |
|---|---|---|---|---|
| gdscript | 68 | export_optimization | 26 | |
| 3d | 57 | ui | 20 | |
| 2d | 40 | data_save | 20 | |
| basics | 36 | shaders | 20 | |
| misc | 33 | animation | 18 | |
| nodes_scenes | 30 | tilemaps | 17 | |
| advanced | 30 | physics | 17 | |
| troubleshooting | 28 | audio | 15 | |
| input + signals + workflow | 28 |
Topic highlights: CharacterBody2D/3D controllers, signals & event buses, state machines, TileMapLayer (4.3+) workflows, collision layers, NavigationAgent pathfinding, AnimationTree/blend spaces, Tween recipes, drag-and-drop UI, custom Resources, save systems & migrations, audio buses & adaptive music, canvas_item/spatial shaders, export pipelines (Steam, itch, Android, iOS, Web), performance profiling, multiplayer (RPC, MultiplayerSpawner/Synchronizer), @tool scripts and editor plugins, and a full troubleshooting category on the classic Godot errors (null references, deferred calls, tunneling, Area2D not firing, …).
Example rows
basics / beginner
Q: What rendering methods does Godot 4 offer and which should I choose? A: Godot 4 offers three renderers, chosen per project in Project Settings → Rendering → Renderer…: Forward+ (Vulkan) is the default desktop renderer with the full feature set — clustered lighting, SDFGI/GI, SSAO… For a pure 2D game, Compatibility is often the pragmatic pick…
gdscript / beginner
Q: How do I use the ternary operator and walrus-like patterns in GDScript? A: GDScript's conditional expression is
value_if_true if condition else value_if_false:var speed := 600.0 if is_sprinting else 300.0 var msg := "%d/%d" % [hp, max_hp] if hp > 0 else "KO"
2d / intermediate
Q: How do I implement a simple quest/interaction NPC system? A: NPCs with dialogue state, proximity prompt, and signal-driven flow:
extends Area2D @export var lines: Array[String] = ["The forest grows dark.", ...] func _unhandled_input(event: InputEvent) -> void: if event.is_action_pressed("interact"): Dialogue.show_lines(npc_name, lines)
Usage
from datasets import load_dataset
ds = load_dataset("0xRavenBlack/godot-gamedev-instruct")["train"]
print(ds[0])
Filtering examples:
# Only beginner GDScript questions
beginner_gd = ds.filter(lambda x: x["category"] == "gdscript" and x["difficulty"] == "beginner")
# Version-sensitive features only
newer = ds.filter(lambda x: x["godot_version"] != "4.x")
Intended uses
- Supervised fine-tuning (SFT) of coding assistants specialized in Godot/GDScript
- RAG knowledge bases for game-dev chatbots
- Question generation / evaluation benchmarks for game-engine knowledge
Out-of-scope / caveats
- Answers target Godot 4.x and will be wrong for Godot 3.x APIs (
setget,instance(), TileMap node, …) - Version-sensitive entries are tagged in
godot_version; treat4.3+/4.4+/4.5+rows as feature-gated - Code samples favor clarity and idiomatic patterns over micro-optimization; always profile for your own game
- Multiplayer and platform-specific (console/porting) answers describe general patterns; verify against current engine docs
Data provenance
Examples were authored and fact-checked against the official Godot documentation and release notes for Godot 4.3–4.5 (including the 4.3 TileMapLayer deprecation, 4.4 typed dictionaries & .uid files, and 4.5 AccessKit/screen-reader support). No scraped content; entries are original write-ups following official API conventions.
Considerations
- Code answers use tab indentation,
:=type inference, and snake_case per the official GDScript style guide - Some answers reference free third-party tools (Dialogic, GodotSteam, gdUnit4) as options, not endorsements
- Downloads last month
- 285