Godot Version
4.5.1.Stable
Question
im not exactaly sure whats going on but with my raycast system, if my players sprite isn’t flipped then point the raycast to the right, and if it is flipped then face it left, pretty simple. now i have a tilemap with custom data attached to the tiles, and ive set it up properly so the raycast can detect the custom data on the tilesets, though for some reason it can only detect the data if the raycast is facing right, so when i flip my raycast to the left or facing upwards to detect the bottom the tile, it cannot detect that theres any data on the tile. why is this exactally??
Picture showing customDataLayer and how ive applied it:
Code for raycast detecting customdatalayer:
if Input.is_action_pressed("Pec") and pec_ray.is_colliding():
var collider := pec_ray.get_collider()
if collider != null:
wallPecing = true
if collider is TileMapLayer and collider.is_in_group("Escalator"):
onEscalator = true
escalatorPecing = true
var layer := collider as TileMapLayer
var hit_pos := pec_ray.get_collision_point()
var cell := layer.local_to_map(hit_pos)
var tile_data := layer.get_cell_tile_data(cell)
if tile_data:
var dir_facing : String = tile_data.get_custom_data("DirectionFacing")
if dir_facing == "Left":
is_left = true
if dir_facing == "Right":
is_right = true
Code for changing raycast’s position and target position:
## UPWARDS PECING RAYCAST FLIPPER
if AnimSprite.flip_h == false:
pec_ray.target_position = Vector2(0, -5)
pec_ray.position = Vector2(2, -1)
if AnimSprite.flip_h == true:
pec_ray.target_position = Vector2(0, -5)
pec_ray.position = Vector2(-2, -1)
else: ## NORMAL LEFT/RIGHT PECING RAYCAST FLIPPER
upPecing = false
if AnimSprite.flip_h == false:
pec_ray.target_position = Vector2(5, 0)
pec_ray.position = Vector2(0, -1)
if AnimSprite.flip_h == true:
pec_ray.target_position = Vector2(-5, 0)
pec_ray.position = Vector2(0, -1)
