I have an array of collides. I want to know how to use the entire array at once instead of typing the same thing all the time for the different collides in the array. For example:
//using c-sharp
Public Collider [] colliders;
void FixedUpdate ()
{
RaycastHit hit;
if (Physics.Raycast(transform.position, Vector3.forward, out hit, 40))
{
if (hit.collider == colliders [0])
//some code...
}
}
Instead of writing “if (hit.collider == colliders [0] || hit.collider == collider [1] || …)” is there a way to type the array once and it applies to every variable inside the array? Or is there a better method than using Arrays?? (I’m new to development and scripting in general)