ShapeCast2D not behaving how I expect

Godot Version



The red line is a ShapeCast2D. It’s anchored when I click down and then the target_position follows the mouse. I want it to report if it’s overlapping with the enemy and the player, but it only seems to only collide with one at a time if I start drawing the line outside the circles. If I draw inside it does collide with both of them. This seems contrary to how ShapeCast2D is supposed to work.

Relevant code:

The circles are set to collision layer 2, and the shapecast is set to only scan layer 2.

Any help is appreciated.