Component.collider is obsolete?

I was making the TANKS! game by watching the tutorial from Unity’s website. In the shell explosion script in the for loop to go through all the collider , it’s showing that collider.Length is obsolete and use GetComponent instead. Can someone help me with that?

Yes, you can’t access colliders with:


Use this instead:

gameObject.GetComponent<Collider> ();

So if you have:

Collider col = gameObject.GetComponent<Collider> ();
Debug.Log(col.length);  // this is wrong! colliders don't have a length

But, colliders don’t have a “length” so you may be looking for something like this instead:

Debug.Log (col.bounds.size);

I’m not totally sure what you are asking, however try using gameObject.GetComponent().Length That may work