You can add exceptions, but the problem there is you have to add every body that you want the ray to ignore, and this can get cumbersome.
The correct answer to this problem is to use the collision layer system. Put the ground/obstacles on one layer and the player(s) on another. Set the raycast's mask to only scan the obstacle layer.
Note that in 3.0, you can assign names to each layer in Project Settings, which makes setting these up a lot more convenient/easier.
That said, if you're using the Physics2DDirectSpaceState.intersect_ray()
method rather than a RayCast2D node attached to your character, then you can't use the names but must pass the method a bitmask for the layers you want it to scan. I don't know the details of your implementation, but it sounds like the node-based solution might be sufficient if all you're using it for is ground-detection.