Create multiple small tilemaps or just a giant?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By PerduGames
:warning: Old Version Published before Godot 3 was released.

I’m not sure if I create multiple chunks (scenes with small tilemaps) or just a scene with a giant tilemap for the map of my game, which would perform better?

And if I create a huge tilemap, how could I optimize it, I think of using an array that saves the position and the current tile, and thus only leave a few cells “painted” (enough to cover the camera2d), as the player moves, I’m painting and erasing the cells in the tilemap, is this the best way to do this? or would it be better to create scenes with small tilemaps and disable them when they are not being watched by camera2d?

:bust_in_silhouette: Reply From: Zylann

The TileMap node already supports chunks internally (they are named “quadrants”, configured by quadrant size property), so you don’t have to worry about not drawing cells outside view. So as long as you’re fine with full loading and memory usage, rendering should stay fast enough.

One situation in which you might want doing chunks yourself is if you have a streamed world, meaning that you won’t be able to have the full world loaded at once (but your world must be very very very big), but even that can also use a single TileMap if you are generating tiles procedurally.

:bust_in_silhouette: Reply From: toxiccrack

I’ve written an example script on how to dynamically show/hide tilemaps, based on the players position:

This got my game from 30fps (all tilemaps visible) to about 500fps (1 tilemap visible) and 140fps (4 tilemaps visible).