As in the first screenshot, the ball is moving in the direction I specified with raycast2d. I show the next direction from the collision point with the second raycast2d, but it acts as in screenshot 2 due to the way the ball collides. How do I get Raycast2d to show the right direction?
Create a new invisible edge for the raycast2d and slide the red edge down the length of the radius of the ball. wall_y_position -= ball_radius.
wall_y_position -= ball_radius
You need to draw the line according to the center of the circle, not the edge.