godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.14k stars 96 forks source link

Add the ability to add custom tags/values to TileMap/GridMap cells #3710

Open ShawkMusic opened 2 years ago

ShawkMusic commented 2 years ago

Describe the project you are working on

A game with a tile/gridmap node

Describe the problem or limitation you are having in your project

I want to make variants of blocks, water to have "strength" levels (the further it flows, the closer it gets to 0), chests to have arrays with what items are stored in it and where, and more.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add the ability to add custom values to each individual cell in a Tilemap/gridmap

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

In the editor, underneath the place where you choose what tile to draw, there could be a menu where you can add custom values to the cell. You would give it a name (that will be used to refer to it in the dictionary) and a value. This would be stored in a dictionary (similar to adding Extra Call Arguments when connecting a signal) These values would be added to the nodes you paint. It would be similar to pressing the flip/rotate buttons above the tiles.

godot_tileprop

In code, there would be new methods:

If this enhancement will not be used often, can it be worked around with a few lines of script?

Yes, but I've needed to do this for nearly every tile/gridmap based game so I think it's worthy of being in core

Is there a reason why this should be core and not an add-on in the asset library?

I've needed to do this for nearly every tile/gridmap based game so I think it's worthy of being in core

Calinou commented 2 years ago

I think TileMap metadata has already been added in the new TileMap editor in the master branch.

KoBeWi commented 2 years ago

Yep, this is missing only in GridMap.

me2beats commented 2 years ago

Yep, this is missing only in GridMap.

should the proposal be renamed then?

Mickeon commented 2 years ago

custom values to each individual cell in a Tilemap/gridmap

This proposal seems to suggest metadata on a cell-by-cell basis, but if memory serves me right, the metadata in the reworked TileMap is on a tile-by-tile basis.

https://godotengine.org/article/tiles-editor-progress-3

"As it was quite a requested feature, TileSet now support custom data layers. Each custom data layer can be assigned a type and a name. Once this is done, each tile of the TileSet can be assigned a value for each custom data layer."

KoBeWi commented 2 years ago

Well, you can have an empty tile with custom data and paint it over cells that you want to use this data. If you put it on a separate layer, it's very easy to work with (edit, retrieve etc.).

Xrayez commented 2 years ago

As an alternative solution to this proposal, there's a special VariantMap class in Goost which allows to encode data in 2D. It can be saved as a general-purpose resource with whatever Variant data in each cell, unfortunately it does not have ability to conveniently edit such data yet (I think it makes sense for VariantMap's editor plugin to be similar to what's proposed in #13, which actually solves a lot of use cases).

Other than that, I approve this proposal in general.