Is there a direct method to get all the objects intersect with a raycast2d.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By alexzheng

For example, I want to query all the objects that intersect with a line from pointA to pointB.
Raycast2D only return the first object.
I know the Physics2DDirectSpaceState can do such task, but it seems a little complicated to construct the query parameter.

For example, a laser shooting from point A to point B, all object between the two points should be attacked.

alexzheng | 2018-08-25 02:22

:bust_in_silhouette: Reply From: kidscancode

Here are some similar questions that have been asked previously, with some suggested solutions:
https://forum.godotengine.org/21646/how-to-detect-object-along-line?show=21646#q21646

https://forum.godotengine.org/28264/possible-to-detect-multiple-collisions-with-raycast2d?show=28264#q28264

The first solution require an additional Area2D, and the second require multiple checks.
Thanks all the same,
BTW, your youtube video is the best channel for Godot.

alexzheng | 2018-08-26 01:27