I’m trying to make conveyors return tile data based on what is colliding with raycasts. I have it pretty much working, but with one issue. If the tile is colliding from the left or top raycast, it cannot find the tile and returns (-1, -1) here is what my code looks like:
if $Raycasts/Left.is_colliding():
raycast_on_wall = true
var tile_map: TileMap = $Raycasts/Left.get_collider(0)
var hit_pos = $Raycasts/Left.get_collision_point(0)
var tile_pos = tile_map.get_cell_atlas_coords(0, tile_map.local_to_map(hit_pos))
tile_map.set_cell(0, hit_pos, 0, tile_pos)
var data = tile_map.get_cell_tile_data(0, hit_pos)
conveyor_detect = data.get_custom_data("Direction")
(For the raycasts I’m using shapecast2ds for a wider detection range, which is why get_collider and get_collision_point includes an index. I still faced the issue when I used normal raycasts)
This is what is returned for each variable
I checked everywhere online for discussions and checked the docs several times, but nothing is talking about why it would be unable to find the tile based on the direction. I checked if it was a tile thing, but it’s not. The code functions fine on the bottom and right raycasts, on every tile. The code in the script and editor is identical. (Yes, the instances where I specify the colliding raycast is different for the seperate types.