- Home /
How to get the number of objects that are on a Raycast Path?
Hi,
I'm trying to fake some fine shadows on a particle system. So far it goes well but I need to know how many other particle systems there are between my particle system and the Sun.
It goes like this: Every particle system has a collider attached. I shoot a raycast from my particle system towards the sun. So far, I was only able to get the info if there is anything at all, but I need to know if there are more colliders on that path because the shadow needs to be stronger in that case.
I've gone through documentation and couldn't find it :(
Thanx, Vladimir
Answer by Bunny83 · Feb 20, 2011 at 10:31 PM
All you need is Physics.RaycastAll. It returns an array of RaycastHit objects.
In your case just check the array length.
Thanx! That's it! I've seen that function but wrongly interpreted it as if it shoots rays all over the place :)
Your answer
Follow this Question
Related Questions
RaycastHit always returns 0 1 Answer
C# raycast shooting script broken 1 Answer
[RESOLVED]Raycast problem 2 Answers
Raycast collision issue 0 Answers
Tree how to add a tag to it when it is apart of the terrain -1 Answers