GaeaChunkLoader
GaeaChunkLoader is a scene node that divides the world into chunks and generates them on demand around a moving actor (typically the player). It is designed for open-world or infinite worlds where the full map cannot be generated all at once.

How It Works
The chunk loader polls the actor's position at a regular interval. When the actor moves into a new chunk, the loader:
- Calculates which chunks fall within the
loading_radiusaround the actor. - Requests generation for any chunk not yet loaded.
- Optionally erases chunks that are no longer in range (if
unload_chunksis enabled).
Chunks are defined by their chunk_size and identified by their integer position in chunk space.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
generator |
GaeaGenerator |
— | The generator node used to generate and erase chunk areas. |
actor |
GaeaChunkLoaderActor |
— | Resource that provides the actor's position in chunk space. |
chunk_size |
Vector3i |
(16, 16, 1) |
Size of each chunk in world units. |
loading_radius |
Vector3i |
(2, 2, 1) |
How many chunks to load in each direction around the actor. |
update_rate |
float |
0.1 |
Interval in seconds between position checks. 0.0 checks every frame. |
start_on_ready |
bool |
true |
If true, starts loading automatically when the node enters the scene tree. |
unload_chunks |
bool |
true |
If true, erases chunks that leave the loading radius. |
Methods
| Method | Description |
|---|---|
start() |
Starts the loading loop. Called automatically on ready if start_on_ready is true. |
stop() |
Stops the loading loop. |
Actors
Actors are small resources that tell the chunk loader where the tracked entity is.
The actor resource must match the type of renderer you're using. For example, if you're using a TileMapGaeaRenderer, use a GaeaChunkLoaderTilemapActor and assign the target TileMapLayer. If you're using a GridMapGaeaRenderer, use a GaeaChunkLoaderGridmapActor and assign the target GridMap.
Two built-in actors are provided:
GaeaChunkLoaderTilemapActor
Used for 2D games with a TileMapLayer renderer.
| Property | Type | Description |
|---|---|---|
tilemap |
NodePath |
Path to the TileMapLayer node. |
player |
NodePath |
Path to the Node2D actor to track. |
The actor converts the player's 2D map position into chunk coordinates automatically.
GaeaChunkLoaderGridmapActor
Used for 3D games with a GridMap renderer.
| Property | Type | Description |
|---|---|---|
gridmap |
NodePath |
Path to the GridMap node. |
player |
NodePath |
Path to the Node3D actor to track. |
The actor converts the player's 3D map position into chunk coordinates automatically.
Custom Actors
You can create your own actor by extending GaeaChunkLoaderActor and implementing two methods:
get_actor_chunk_position(chunk_loader, chunk_size) -> Vector3i— returns the current chunk position of the actor.is_actor_valid(chunk_loader) -> bool— validates that required nodes are present.
Setup
- Add a
GaeaChunkLoadernode to your scene. - Assign your
GaeaGeneratornode to thegeneratorproperty. - Create a
GaeaChunkLoaderTilemapActororGaeaChunkLoaderGridmapActorresource and assign it toactor. - Set
chunk_sizeandloading_radiusto match your game's scale. - Run the scene. The loader starts automatically and generates chunks as the player moves.