godot raycast2d doesn't exclude parent

GDScript's RayCast2D does not have a built-in option to exclude the parent object from collision detection. However, you can manually exclude the parent object by checking the object returned by the get_collider() method against the parent object. Here's an example:

extends RayCast2D

var parent_object: Node2D

func _ready():
    parent_object = get_parent()

func _process(delta: float):
    # Perform raycast
    var collision = get_collider()

    # Check if the collision is the parent object
    if collision != parent_object:
        # Process the collision as needed
        pass

In this example, we store a reference to the parent object in the parent_object variable during the _ready() function. Then, in the _process() function, we perform the raycast and check if the collision is the parent object. If it is not, you can process the collision as needed.

Please note that this is a manual workaround and may not be the most efficient solution depending on your specific use case. If you require more advanced collision filtering, you may need to implement your own custom solution using groups or layers.