Can you detect a tiles position and id with an Area 2D?

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

extends KinematicBody2D

var tile_map
var tile_pos
var tile_id

func _physics_process(delta):

tile_map = get_parent().get_node(“TileMap2”)

func _on_Area2D_area_shape_entered(area_id, area, area_shape, self_shape):
tile_pos = tile_map.world_to_map(collision.position - collision.normal)
tile_id = tile_map.get_cellv(tile_pos)

#In my game the player dosen’t collide with the tiles
#So i’ve been trying to uses signals to detect the tiles pos/id but it seems that i can’t do it without collision

TileMaps have bodies and not areas, you need to look for bodies entering instead.

exuin | 2021-04-13 01:10