how to make a list of raycasts code example

Example 1: get transform from raycast array

//you sould be able to get away with something like this:
RaycastHit2D hit = Physics2D.CircleCastAll(currentSoldier.transform.position, currentSoldier.weapon.range, new Vector3(0, 0, 0), 0f);
transform transform = hit.transform;

Example 2: get transform from raycast array

RaycastHit[] castArray = new RaycastHit[14];   
  RaycastHit[] f = Physics.RaycastAll (transform.position,transform.forward,50);    
  for (int i = 0; i < f.Length; i++)  
  {     
  		if (f[i].transform != transform && f[i].collider.tag != "Terrain")      
        {          
        	castArray [0] = f[i];
            fDetected = true;
        }
 }

Tags:

Misc Example