Godot Version
v4.3 stable
Question
Hi everyone! I’m using two raycasts to detect the type of ground under my player. I added two raycasts on each side to detect the type of wall.
The two raycasts pointing to the right correctly detect the wall, but those pointing to the left do not.
func handle_tilemap_collision(ground_tile: TileMapLayer) -> void:
var collision_point = self.get_collision_point()
#print("Collision POINT ", collision_point)
var local_collision_point = ground_tile.to_local(collision_point)
#print("LOCAL Collision POINT ", local_collision_point)
var tile_pos :Vector2i = ground_tile.local_to_map(local_collision_point)
#print("Tile POS ", tile_pos)
var data :TileData = ground_tile.get_cell_tile_data(tile_pos)
#print("Tile DATA ", data)
if data:
ground_mask = data.get_custom_data_by_layer_id(0)
else:
print("no data !")
I’ve checked every line on both sides, and the ’ tile_pos ’ coordinates are the same on both sides. The issue seems to come from this line:
var data :TileData = ground_tile.get_cell_tile_data(tile_pos)
The raycasts with a negative ’ target_position ’ print : Tile DATA ", <Object#null>.
Thank you for your time. If you need more info, just let me know.