- Home /
Multiple linecasts question
Hey,
I have a projectile with two linecasts, i want to perform an action when one of them hit for example, is there a simple way to check if any of the linecasts hit or do i have to check them individually like:
if(ray1.collider != null || ray2.collider != null)
{
//do something
}
It seems messy, what if i had a dozen of casts, i'm sure there is a better way to do this.
if you want to repeatedly check multiple things of the same kind (did I hit something?) I'd write a separate method and run it in a loop:
PseudoCode:
RaycastHit hit;
for (times I want to check rays){
if(CheckRay(direction, out hit))
Resolve(hit);
}
Answer by Khena_B · Feb 03, 2017 at 09:16 AM
The loop approach from this thread worked perfectly, thanks!
Your answer
Follow this Question
Related Questions
RayCast or LineCast? 1 Answer
Vehicle is vibrating on the edge of the ramp/surface when I get the normal of the surface 0 Answers
Raycast stop at distance 3 Answers
Raycasting along line renderer width 1 Answer
Linecast from raycast hit point 1 Answer