Related to: https://godotforums.org/discussion/24058/how-to-make-my-character-never-stuck-in-tiles
This is my code:
extends Node2D func _process(delta): #NodeD2 = center of the viewport. if Input.is_action_just_pressed("ui_accept"): if $NodeD2.scale.y == 1: $NodeD2.scale.y = -1 else: $NodeD2.scale.y = 1 if Input.is_action_just_pressed("ui_cancel"): if $NodeD2.scale.x == 1: $NodeD2.scale.x = -1 else: $NodeD2.scale.x = 1 var cell = $NodeD2/TileMap.world_to_map($Player.get_position()) var tile_id = $NodeD2/TileMap.get_cellv(cell) print(tile_id)
Maybe try using $Player.get_global_position instead of $Player.get_position()?
$Player.get_global_position
$Player.get_position()
Thanks! Now i realize that you never mentioned the use of get_cellv() and it was justprint(cell) to get player position (however, get_cellv() still gives me -1 and that doesn't happen with get_cell()) Edit: Nevermind, solved it.
get_cellv()
print(cell)
get_cell()