Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | VolatileAgent |
I am trying to locate a specific tile index in a TileMap. When TileMap.get_used_cells_by_id() returned no cells, I decided to look at the tile indices for the whole map. I used the following in a function called from the _ready function for my main scene, of which the TileMap is a child of a scene which is a child of the main scene:
for cell in $BasicMap/TileLayer1.get_used_cells():
print("Cell ", cell, " = ", $BasicMap/TileLayer1.get_cellv(cell))
This prints 0 as the tile index for every cell, despite the tilemap displaying correctly.
Is _ready the wrong place to call this, or is there something else I’m doing wrong?
“This prints 0 as the tile index for every cell, despite the tilemap displaying correctly.”
I would think you’re calling it prematurely. Paste that code in _Process()
then set_process(false)
after the loop.
timothybrentwood | 2022-12-22 04:53
Same result.
VolatileAgent | 2022-12-22 14:44