#Access a scene tile's node from position ?

14 messages · Page 1 of 1 (latest)

thick jetty
#

Hello, I have a tilemap with some scenes representing world objects (say tree or rocks), is there any simple way to access such a tile corresponding node (in a script) just with its position in the tilemap ?

thick jetty
#

Found a way to do it, made a general script that I attach to every object tile that adds itself to a (position):(self) dictionary in the parent tilemap, idk if it's optimal but it works

reef oasis
#

Hello 😊
Do you create your own tilemap node or use godot one ?

twin tartan
#

@thick jetty get_cell_tile_data ( int layer, Vector2i coords, bool use_proxies=false )

#

However you get the coords of the tile, pass it into this function. You may have to use, tilemap.local_to_map(vector2) first to convert to local tilemap coords.

thick jetty
#

I use the Godot tilemap node, and okay thanks for the help I will try it when I get back to it :)

reef crater
twin tartan
#

@reef crater I see, I wasn't sure if you was using scene tiles, the only way I could find to reference scene tiles was after you create the tile, I use a dictionary with the location as the key. Then I just checked the dictionary for the tile.

reef crater
# twin tartan <@314951308656377863> I see, I wasn't sure if you was using scene tiles, the onl...

Yeah that's basically what I'm doing too. I'm not the op but I was searching for an unrelated scene tile issue. I'm used the child_entered_tree signal on the tilemap to get a reference to the node, and then add that to a dictionary in just that same way.

The issue btw was that you can't re-instantiate a scene tile on the same tile, after it's been already placed and deleted (tile set to empty tile, and scene freed). The issue is fixed on the latest version https://github.com/godotengine/godot/issues/82597

GitHub

Godot version 4.2 dev 4 System information Godot v4.2.dev4.mono - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2070 Super (NVIDIA; 31.0.15.3713) - Intel(R) Core(TM) i7-1087...

reef crater
#

Are you using the latest version?

twin tartan
#

Yes, not the beta. 4.1.2

reef crater
twin tartan
# reef crater That's the one i was using, and having this issue on.

Yeah, for now you can't access scene tiles from the tilemap, not sure if it will be something they look into doing. A simple workaround I found was the dictionary. As a side note, I'm in the process of scrapping my scene tiles and just open the functionality of the tilemap.