1 tilemap vs multiple tile maps

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By IHate

I’m want to implement a world in which the player is able to add chunks of 30x30 tiles, tile’s size will be 32x32 or 16x16 if the performance tanks. Every chunk has a road with a starting point and an end point both must be at the limit of the chunk but on different directions. These chunks are generated by an algorithm at runtime and they need to know if they have another chunk next to them in order to connect the roads properly. I thought about saving every chunk I place as a tile on another tilemap that would serve me just to keep track of all the chunks and their data.

But how do I manage these chunks? I was testing with multiple tilemap nodes but I read about people talking the quadrant size and having just 1 tilemap would make managing the logic much easier. What is the easiest way to copy the tiles from one tilemap to another but starting from an specific tile position? Is getting the used_cells and adding the new starting position the best way?

What are the pros and cons of 1 tilemap vs multiple tilemaps?

:bust_in_silhouette: Reply From: Lopy

You do not need a second TileMap if you only plan on using it for storing information. A Dictionary would be more appropriate. Tis is because most of the features of TileMaps are only useful when seen.

You would have code looking like that:

my_dictionary[chunk_vector2] = info

Where “info” is either another Dictionary ( {door1=Vector2(0,10), door2=Vector2(17,30)} ), or another script (extending Reference as opposed to Node, and with a var for each information).

Remember to divide/multiply your vectors by chunk size when switching bewteen chunks and tiles. Consider taking a naming convention for you variables to know in which dimension they are expressed.

I actually have that system in place already for every tile in the map saving all the logic in the tiles there’s a lot of stuff like events/effects, combat info,doors, dialogues, etc…
I can do as you say and save that into another dictionary with a key for every chunk.

My idea for the second tilemap was to be quickly for check if what chunks are surrounding the current one and display a minimap I thought this would be faster to check than getting the key in a huge dictionary. But maybe it’s not that cumbersome.

But what about splitting each chunk into different tilemaps? Does anyone have experience with that? for what I read most people seem to go with multiple tilemaps and I haven’t read much about using only the logic of the tiles seems to work even out of the quadrant range, so to stop the logic I would have to clear the tiles on that chunk isn’t that more taxing that just unloading and loading a new tilemap scene?

IHate | 2021-04-07 21:52