Get all Colliders

In Unity version 3.3 I had this code working:

colls = gameObject.FindObjectsOfType(Collider)

Now it throws the error "Cannot convert “UnityEngine.Object” to “UnityEngine.Collider”.

So how’s the correct way to get those Colliders?

What about:

colls = gameObject.FindObjectsOfType(Collider) as Collider[];

Assuming that colls is type of Collider

I already tried this.

colls = gameObject.FindObjectsOfType(Collider) as Collider

Then I get the error "Cannot convert “UnityEngine.Collider” to “UnityEngine.Collider”, which is pretty weird.

Does not work with the brackets (I’m scripting in boo)

Try this (I found it in the script reference):

colls as (Collider) = FindObjectsOfType(Collider)

It always helps to have a look at the script reference first.

ok, here is how it finally worked for me:

In the class ‘PlayerController’ (remember, I’m in boo) I declare:

private colls as (Object)

In the method “Start”, I initialize:

colls = gameObject.FindObjectsOfType(Collider)

Later, in another method, I use this array:

`for coll as Collider in colls:
   [more code]`