![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | nake |
Hello!
I’m quite new to the engine and I got stuck with the tilemaps in godot 4.
Long story short: I want to get the node of a placed tile by its coords to be able to change some properties from gdscript. However, that tile is an scene instead of a normal tile, so I did not place it myself and the name in the tree is auto-generated.
I can check the scene node tree during gameplay and confirm that each node exists there, so my guess is that there is some kind of tilemap → node list somewhere. However, maybe it is not directly exposed to the user?
I noticed in the engine source code that there is a function that might do what I want, but it is not exposed (in scene/2d/tile_map.h):
// Not exposed to users
TileMapCell get_cell(int p_layer, const Vector2i &p_coords, bool p_use_proxies = false) const;
I’m not sure if there is a way to access that node somehow that I am not aware of (still really new to this), or maybe it is a feature not added yet (as this is a very new feature of tilemaps).
Any ideas?
For a more tangible example:
I’m making a top-down game (imagine hotline miami or darkwood top-down style).
The player is in a ship that I create with a tilemap. (normal tiles)
The ship has tiles that you can interact with. For example, doors. (scene tiles)
At startup, I want the ship script to change some data about the doors depending on their position in the ship. I have some logic that can give a list of doors to change but I am failing to get the door node given the cell coordinates.
I guess in the worst case scenario, I could just create the doors myself instead of using the tilemap, but with the new feature in godot 4 of being able to place scenes as tiles, I kinda feel there must be an easy way to do this. And I can also see others asking similar questions when godot 4 releases.
Thanks in advance!