How to store additional information with a TileMap node?

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

I found some old code of mine and managed to write a GDScript to import the old binary level data and convert it into a TileMap (this is so cool! I love Godot more and more!). This runs as a tool in the editor and creates one TileMap per level on the fly and adds them to the editor’s tree.

Looking at my code from back then, every tile could have a mode. Example: the tile is a concrete block you can walk on but its mode could be set to “background”, thus the player would fall through it. Or the tile is something that looks like it can be collected but its mode is set to “kill”, so the player would die.

How would I replicate this in Godot? Where should I store this information?
Here’s what I am currently thinking about:

  • set_meta() on the TileMap and store a mapping in there for each tile?
  • create my own node subclass and add it as a child to the level TileMap?
  • Read my binary data and transform it into JSON and store as a resource?
  • Read binary data and transform into GDScript and paste into my code?

So just to make it clear: I do not want to store properties in the TileSet but in the individual tiles the TileMap is built from.

I don’t know if this exists in Godot. Maybe you can try using an array in the tilemap and link that to get_used_cells_by_id().

lavaduder | 2019-01-04 14:09