convert a collider array to a list transform

hi there.

my problem is: i want to use overlapsphere to find some objects in range but overlapsphere gives me only a collider array as output…

what is the best way to convert this array to a list?

I’m not sure if this is what you need, plus I’ll give you UnityScript, but here’s the idea:

Colliders and transforms are components attached to gameObjects. So to get the transform from a collider, you can do collider.gameObject.GetComponent(Transform);

Code:

function CollidersToTransforms(cols:Collider[])
{
    var transformsList = new List.<Transform>(cols.length);
    for(col in cols)
    {
        transformsList.Add(col.gameObject.GetComponent(Transform);
    }
    return transformsList;

}

I hope it helps!