How to Less Than or Equal to with a Raycast?

Hey everybody,

How do you code from <= 300 on down to 0 in the following?

    if (Physics.Raycast (transform.position, down, 300)) {
    	
           //DoSomething
        
    }

Thank you.

Do you mean, you want a list of everything out to 300, sorted from furthest to closest?

If so, RaycastAll will give you the list, in no special order (I seem to recall it tends to be sorted 1st to last, but the docs say it isn’t.)

You can use any standard way to sort that list yourself (not a Unity thing, but maybe someone has a good javascript sort here.)