Home > database >  How to store Tilemap data efficiently?
How to store Tilemap data efficiently?

Time:09-19

I'm working on a little game where tilemap gets generated. This is so far not done in chunks and pretty basic. Single tiles (rule tiles) of the tilemap can be destroyed by the player. This is working so far (and took me long enough to figure out!)

Now I am looking for a way of saving tilemap data that allows me to give each tile a specific amount of lifepoints (so that the player needs to hit harder tiles twice oder three times before they get destroyed. Also upon destruction I want the tiles to be able to drop loot (like gems).

How would you go about this? I thought about putting gems etc. on a different (visible) tilemap and while destroying the tile of the "ground" tilemap check if for the same position of "gem" tilemap there is an object. If so destroy it and drop item to be picked up by the player.

I'm quite lost on this one, so every input is very welcome! Thanks.

CodePudding user response:

What you are looking for is Scriptable Tiles, or alternatively Scriptable Objects.

You can look for simple tutorials like this.

  • Related