Godot Version
4.3 stable
Question
Hello
I’ve been using the new TileMapLayer nodes, and I’ve got a physics layer on each placed cell to detect collisions with an Aread2D on the player.
I then use _on_body_shape_entered()
to detect collisions, and run TileMapLayer.get_coords_for_body_rid(body_rid)
to detect cells that are inside the area. However, even though this works, I’m getting thousands of errors in the debugger:
I looked into the Godot source, and it seems to be related to this section in tile_map_layer.cpp:
Vector2i TileMapLayer::get_coords_for_body_rid(RID p_physics_body) const {
const Vector2i *found = bodies_coords.getptr(p_physics_body);
ERR_FAIL_NULL_V(found, Vector2i());
return *found;
}
At a guess, it’s looking for a p_physics_body
and not finding one, and calling ERR_FAIL_NULL_V
with no found parameter, and giving an error. I tried adding:
if not tiles.has_body_rid(body_rid): return
before the get_coords
call to stop it checking RID on a cell that’s empty or not in the tile map, but it’s not catching it there. I suppose it’s working fine, but what am I doing wrong to be throwing so many errors with each collision detection?