How to get the number of objects that are on a Raycast Path?


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

All you need is Physics.RaycastAll. It returns an array of RaycastHit objects.

In your case just check the array length.