get_tile() function of TileMap node always return -1 (Invalid cell) no matter where the position argument is.

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

The TileMap has Grass Tiles on every 50x50 corner of the map.
yet when the function of get_tiles() argument is inserted with the tile position from the world to map position of global mouse position from get_global_mouse_position().

the function always return -1 (Invalid_tiles).

can you guys give me any solution? did I do some mistakes? I will appreciate it greatly.

I called the get_cell function on _process(delta) rather than a made function.

and it returns 0, this proves that the problem is in the function.

something prevents the get_cell function from working properly on a programmer-made function.

Qri_dev | 2022-08-24 10:32

:bust_in_silhouette: Reply From: Qri_dev

The Answer has been answered on Godot Discord by Parapixel

The if not set_cell == 0:

caused the tile to be removed which cause that.