Question by
SuperRaed · Sep 28, 2017 at 04:51 PM ·
raycastraycasthitphysics.raycast
How can a Ray detect more than one object in it's casted direction?
I have two objects located in a ray's direction, one behind the other, as in the picture I'm looking for a way to detect them both using ray, but so far only the object A, the one in front, is being detected. how can I return both as Raycast hits?
raydelimma.png
(9.1 kB)
Comment
Answer by FortisVenaliter · Sep 28, 2017 at 07:38 PM
Use Physics.RaycastAll(). But then you have to go through and filter to process only the hits you want.
Your answer
![](https://koobas.hobune.stream/wayback/20220612135836im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
[fixed] My physics.raycast vision doesn't work as I expect it to, and I don't know why 2 Answers
Raycasts stop working after ~3 seconds 1 Answer
raycast not hittig anything but charecter 0 Answers
Swipe single object at a time upon touch, not swiping allover the screen 0 Answers
BulletHole and HitSparks spawning in front of weapon 0 Answers