Skip to content
Back to skills

Godot Scene Flow

ASecurity

Godot game flow: autoload singletons, scene changes and loading screens, pause, save and load to user://, checkpoints, object pools.

  • 5 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 3, 2026
ai-agentspythongobashnodetesting

Security analysis

A100/100

Pro scans all 10 files and shows the line behind each finding

Scanned December 3, 2026

npx -y skills add tipoLi5890/game-studio --skill godot-scene-flow --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Godot Scene Flow?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Godot Scene Flow
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tipoli5890-godot-scene-flow/badge)](https://www.skillsdirectory.com/skills/tipoli5890-godot-scene-flow)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: godot-scene-flow
description: >-
  Godot game flow: autoload singletons, scene changes and loading screens, pause, save and load to
  user://, checkpoints, object pools.
---

# godot-scene-flow — boot, change, pause, save

Autoloads hold what outlives a scene; everything else is loaded, changed and freed. Most flow
bugs are one of three: code that runs in a scene that is already freed, a value read before the
scene change finishes, or a save that comes back with different types than it left with.

## Load what the situation needs

| The situation | Read |
|---|---|
| What belongs in an autoload; GameState; an autoload a SceneTree script or a test cannot name | `reference/autoloads.md` |
| "Go to the next level"; a loading screen with progress; `current_scene` is null after a change | `reference/loading.md` · `resources/scene_loader.gd` |
| Pause: something keeps moving behind the menu, or the menu itself froze; a timer that fires while paused | `reference/loading.md` → "Pause" |
| Saving and loading; a save that comes back as floats; versions and migrations; where `user://` is | `reference/saving.md` · `resources/save_store.gd` |
| Respawning at a checkpoint; pickups, sparks or shots spawned many times a second | `reference/pools-checkpoints.md` · `resources/node_pool.gd` |
| The pause menu, the loading screen's layout, the HUD that listens to GameState | `godot-ui` |
| Scene and resource text, ids, building a scene in code | `godot-scene-files` |
| The `[autoload]` and `run/main_scene` lines of a new project | `godot-new-project` |
| Typed GDScript, signals and `await` in general | `godot-gdscript` |
| Proving the change runs headless, the verdict | `godot-verify` |

## The files

Copy `resources/` into the project (say `res://flow/`); none of the four depends on another or
on its own path, so any folder works.

| File | What it is | Register |
|---|---|---|
| `resources/game_state.gd` | run state: route, parcels delivered, checkpoint; `to_save()` / `from_save()` / `migrate_step()`; signals `parcels_changed`, `checkpoint_reached`, `run_reset` | autoload `GameState="*res://flow/game_state.gd"` |
| `resources/scene_loader.gd` | threaded scene change: `change_scene(path)`, signals `progress_changed`, `scene_ready`, `load_failed`; runs while paused | an autoload under your own name, or a child of the root |
| `resources/save_store.gd` | versioned JSON slots (atomic write, migrations, refusals) and Resource slots (cache-safe) | `preload`, no global name |
| `resources/node_pool.gd` | `acquire()` / `release()` over a fixed set of instances | `preload`, no global name |

GameState is the courier-run example: rename its fields for the game, keep the shape (data and
signals, a save version, one migration step per version).

## How a scene change goes

```text
change_scene_to_file / change_scene_to_packed
  -> returns OK at once; current_scene is null from here
  -> old scene leaves the tree (its _exit_tree), and is freed with every node and coroutine in it
  -> new scene enters the tree, its _ready runs
  -> SceneTree.scene_changed fires; current_scene is the new scene
```

- **Wait on `scene_changed`, never on N frames.** `current_scene` is still null one frame after
  the call.
- **The caller usually dies with the old scene.** A level script that changes the scene cannot
  `await` anything afterwards: its coroutine is dropped when it is freed. Follow-up work belongs
  in the new scene's `_ready`, in GameState, or in the loader's `scene_ready`.
- **A threaded request for a missing file returns OK** and fails later on the loading thread;
  `scene_loader.gd` checks `ResourceLoader.exists` first and refuses with `ERR_FILE_NOT_FOUND`.

## Pause in one screen

`get_tree().paused = true` stops every node whose `process_mode` resolves to pausable, which by
inheritance is everything:

| Node | `process_mode` |
|---|---|
| gameplay: courier, sentries, gates | `PROCESS_MODE_INHERIT` (the default) |
| the pause menu and its children | `PROCESS_MODE_WHEN_PAUSED` |
| the scene loader, a music player that keeps playing | `PROCESS_MODE_ALWAYS` |
| a parked pool instance | `PROCESS_MODE_DISABLED` |

`get_tree().create_timer(t)` is **not** paused by default (`process_always` is true): gameplay
delays use `create_timer(t, false)`.

## Saving in one screen

- Under `user://`, in a JSON envelope `{"version", "saved_unix", "data"}`; `save_store.gd` writes
  a temp file and renames it over the slot, so a crash mid-write keeps the last save.
- JSON returns every number as a float and engine types as strings: write only JSON types in
  `to_save()`, check and convert in `from_save()`.
- Bump `GameState.SAVE_VERSION` with every change of shape and add a step to `migrate_step()`;
  a save from a newer build is refused, never half-read.
- A `.tres` save runs any script embedded in it when loaded: only for files this game wrote.
- Load Resource saves with `ResourceLoader.CACHE_MODE_IGNORE`: the default returns the instance
  still in memory, with the old values.

## Discipline

- **Hold ids, not nodes, across a change.** `checkpoint_marker = &"Ledge"` survives; a `Node`
  reference is a freed object one change later.
- **One owner per state.** GameState owns the run, the pause menu owns `paused`, the level
  owns its pool. A second copy of the parcel count in the HUD is the one that is wrong.
- **Signals out, calls in.** Scenes call `GameState.deliver_parcel(1)`; GameState emits
  `parcels_changed` and never calls into a scene.
- **A save that fails is a value, not a crash.** Branch on `store.last_error`; a missing save on
  first launch is normal.
- **Prove it across processes.** A save loaded back in the process that wrote it can come from
  the resource cache; a round trip counts when a second run reads it.

## Verifying it headless

`scripts/scene_flow_check.py` runs these resources in a real Godot, in temp projects outside the
repository, and deletes the temp `user://` folder afterwards:

```bash
GODOT_BIN=/path/to/Godot python3 scripts/scene_flow_check.py --selftest
python3 scripts/scene_flow_check.py save-info path/to/slot1.json --expect-version 2
GODOT_BIN=/path/to/Godot python3 scripts/scene_flow_check.py user-dir path/to/project
```

The selftest changes scenes by file and through the loader, refuses a missing scene, changes
while paused (a default node stops, an `ALWAYS` node and a default `create_timer` run), respawns
at a checkpoint, reuses a pooled instance, then saves in one process and loads in a second: the
round trip with a random token, a version-1 migration, a too-new and a missing slot refused, a
Resource slot rewritten while held. A third run with the wrong token must fail. Exit 0 pass, 1 a
failed selftest, 2 a failed `save-info`, 3 no Godot or no sentinel (nothing verified).

The selftest runs on the desktop it is started on: run `user-dir` and a save round trip on
web, mobile, Linux and Windows targets themselves. A loading screen's look needs a window
(`godot-play-harness`).

## Scope — what this skill does NOT do

| Not here | Go to |
|---|---|
| Menus, the pause screen, a progress bar's look | `godot-ui` |
| Writing or reading `.tscn` and `.tres` text | `godot-scene-files` |
| Project settings, folders, the main scene | `godot-new-project` |
| Typed GDScript, signals, `await`, warnings as errors | `godot-gdscript` |
| Unit tests of save logic | `godot-testing` |
| Booting straight into a moment of the game, journeys | `godot-play-harness` |
| Frame time of spawning with and without a pool | `godot-profiling` |

Files in this skill

  • SKILL.md7.4 KB
  • reference/autoloads.md4.3 KB
  • reference/loading.md5.3 KB
  • reference/pools-checkpoints.md4.1 KB
  • reference/saving.md6.2 KB
  • resources/game_state.gd3.3 KB
  • resources/node_pool.gd2.8 KB
  • resources/save_store.gd5.3 KB
  • resources/scene_loader.gd3 KB
  • scripts/scene_flow_check.py25 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.