DEV Community

Katana Works
Katana Works

Posted on Originally published at learn.katanaworks.dev AI-assisted

Dynamic Multi-Level Loading in GDevelop (Without Duplicating Scenes)

If you’re building a multi-level game in GDevelop, you do not need a separate scene for every stage. There’s a pattern using global variables and external layouts that keeps your entire game running on a single reusable scene.

Here’s how it works at a high level.

One global variable drives everything. Create a number variable called current_level in your project’s global variables. Initialize it to 1. This is your level pointer.

External layouts hold level geometry. Instead of new scenes, you create external layouts named with a consistent pattern — Level1, Level2, Level3, etc. Each layout uses your main game scene as its base, so it has access to all existing objects.

Dynamic loading at scene start. In your main scene’s event sheet, add a “Beginning of scene” event with the action “Create objects from external layout.” The layout name is an expression:

"Level" + GlobalVariableString(current_level)

Set X, Y, Z origin to 0. Add a Trigger Once condition so it doesn’t fire every frame.

Level transitions. When the player collides with a door and presses the interact key, increment current_level by 1 and change to the same scene. The scene reloads, the beginning-of-scene event fires, and the next layout gets pulled in automatically.

Don’t forget camera boundaries. If your levels are different sizes, you need per-level camera boundary logic. Check the value of current_level and set boundaries accordingly, or your camera will float off into empty space.

This pattern scales well — I’ve used it on projects with 20+ levels and the project file stays manageable. No duplicated event sheets, no object sprawl across scenes.

I made a video walkthrough that covers the full implementation if you prefer to see it built step by step:
https://youtu.be/KBtNvKsRlwk

Top comments (0)