Skip to content

Giving tiles a property dictionary #12634

Description

@timschellenberg

One very, very basic TileSet functionality that I believe to be missing is a simple dictionary to hold miscellaneous data, which other nodes in the scene can then read to be aware of how exactly they should treat the tile.

I've personally seen this feature in almost every single tilemap implementation I've seen and think it's pretty essential.

To give you an idea of what exactly I mean, we can use Tiled as an example:
propertydict
This tile, I would like to hurt any character that touches it. Of course, I'm not expecting the tile itself to run this code or be aware of anything, but for my characters to be able to see a tile they are colliding with and check its property dictionary for an "ontouch" value and do whatever that value tells them, in this case run a routine to hurt the player.
Another example I would actually like to use is, can you see that ice block on the left of that image? I gave it a property of "friction" with the value 0.3, which I would like to be able to read from within the game to adjust my character physics while walking over this tile. (This friction value isn't related to the built-in physics engine, it's just for my own KinematicBody physics handling.)
These applications are I think the most important reasons to implement something like this, just because I think it's actually impossible to get this sort of effect in Godot in any way at the moment, because these rely on the tile's own collision shape. The only workaround would be to completely strip the tiles' collision shapes and manually place TileMap independent staticbodies that can handle this interaction, which is... not optimal. Error-prone, inaccurate, cumbersome, all the bad things.

Similarly, I may want to run a script on level-load that places an object, such as a particle emitter, over specific tiles. It would be very helpful if I had some way to communicate to that script what type of particle emitter should be placed, and that one should be placed at all via these tile properties.
I realize that this example in particular could be done manually by hand, but so could a lot of things that a game engine is there to alleviate!
Another issue with doing it by hand is the much higher chance to make mistakes or to forget placing something.

I've seen people recommend to check the tile number in the TileSet resource and act on that, but I personally am not very happy with how inflexible this suggestion is. I may have different TileSets with different tiles in the same tile number slot, because a dozen tiles used in one TileSet would make no sense to even have in the other, so if I were to go by tile numbers then I would have to insert a lot of empty tiles just to make it fit.
Not to mention how hard to manage such a system would be in a bigger game, as well as its unintuitiveness.

The TileMap node and its lack of features is easily one of Godot's biggest 2D weaknesses, which is why I find myself having to resort to external tools (Tiled) to design my maps, and while it's absolutely no shame for an editor feature in an all-purpose editor like this to lose out to a specialized tool developed for exactly this use in terms of comfort and usability, it's not a great feeling to be stuck without a way to actually implement any sort of game logic inside the game based on a TileMap, something that even Tiled thought of.

Thanks in advance to anyone who may consider this idea, it'd really make me very happy if this were to actually be implemented eventually, especially since I personally feel like it's actually not that complex of a change!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions