#Issues with RayCast2D

1 messages · Page 1 of 1 (latest)

velvet drift
#

I have no idea why I am having issues with RayCasts, but i have looked at the docs, printed out the objects to see what is going on, and I cannot for the life of me figure it out.

I have 4 raycast2d nodse, all under a parent Node2D called raycast. The raycasts are positioned to detect walls (see image). However, the left raycasts will detect the wall but neither of the two right raycasts will detect a wall. THe target point for each raycast is 5 pixels left or right of the players hitbox. Any ideas as to what is going on because I am baffled.

Code:

# Raycasts
@onready var RCTopRight = $Raycasts/TopRight
@onready var RCTopLeft = $Raycasts/TopLeft
@onready var RCBottomRight = $Raycasts/BottomRight
@onready var RCBottomLeft = $Raycasts/BottomLeft

# Function to detect walls
func GetNextToWall():
    if (RCTopLeft.is_colliding() and RCBottomLeft.is_colliding()):
        print("WALL LEFT")
    if (RCTopRight.is_colliding() and RCBottomRight.is_colliding()):
        print("WALL RIGHT")

Thank you for the help!

velvet drift
#

Using visible collision shapes the ray casts needed to be slightly repositioned