get_cellv() only returning 0 as index using autotile

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By sian2005

Hello there,

When I want to get the tile index, I use ex. GrassTilemap.get_cellv(pos)

that, when collided, returns always 0 (not the correct index) and if not, -1.

Does anyone have any idea how to get the right index?

Kind Regards, sian2005

:bust_in_silhouette: Reply From: Merlin1846

0 is the index and -1 means the tile is empty if you have more than one tile it may say 1,2 ect for the index.

:bust_in_silhouette: Reply From: njamster

Doing

GrassTilemap.get_cellv(x, y)

will give you the id of the autotile-set. If it’s zero, then it should be the first entry in the list of tiles when selecting your GrassTileMap-node.

To get the id of the subtile instead, you have to use:

GrassTileMap.get_cell_autotile_coord(x, y)

It will return a Vector2, where (0, 0) equals the subtile in the top-left of your autotile-texture, (1, 0) will be the one to the right and (0, 1) the one below it.