0 votes

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

in Engine by (26 points)

2 Answers

0 votes
Best answer


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.

by (10,580 points)
selected by
0 votes

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.

by (617 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.