Need help with ground detection in an rpg

Godot Version



The code I have below is made to detect if there is ground beneath me in an rpg, however it does not seem to work.

const LAYER = 0
const GROUND_TILE = 0
var source_id = tile_map.get_cell_source_id(LAYER, tile_map.local_to_map(global_position))
if source_id == GROUND_TILE:

It prints splash even when I am on land.

I should mention this is all within the main node (all other nodes are a child of it) and this code is in process delta

Heads up for whoever, see also:

Um… yeah. I’m the guy who got that code. I modified it a bit and know no matter what I do, even if I copy and paste the original, it doesn’t work.

It prints -1 (no tile detected when I am close to the edge.