Chunking tilemaps

Hi @CrazyAmphibian !

Personally, if the size of the map is beg enough, I’d author the map as a single .tilemap.
Then I’d write a python script (or other scripting language), to split that big tile map into smaller ones (our file formats are protobuf text!), and also create a collection (e.g. bigmap.collection) with collection proxies in them. These scripts can be run before a build starts, using our .editor_script.

Each collection proxy points to a collection (e.g. piece00x12.collection) and it in turn points to the smaller tilemap (e.g. piece00x12.tilemap).

The bigmap.collection also will point to a script that can receive messages that deal with loading unloading the map pieces.

There are multiple ways of doing this, but this is the main idea.

By using collection proxies (as opposed to collection factories), I can separate the resource loading, so that the tilemaps (and possibly other resources, such as sounds/music) can be loaded/unloaded as the player moves along.

Another thing to look out for in a very large map is floating point precision, which may make things look strange/buggy when the camera is far from the origin (0,0).
A common way to deal with that is to keep the map pieces and the player close to origin, by moving them accordingly. An example of this is an infinite runner game: The player doesn’t move, but the game world does!

4 Likes