Hi there, I’m trying to get the size of all the colliders put together on an object, but for some reason it only gets the bounds of the first collider. I’ve checked and it is running through all the colliders attached to the object, but no matter how I change the colliders, or how much manual garbage values I throw into the Encapsulates function the “bounds” variable doesn’t change from the first one.
bounds = new Bounds();
Collider2D[] colls = GetComponents<Collider2D>();
if (colls.Length > 0)
{
foreach (Collider2D coll in colls)
{
if (!coll.isTrigger)
{
if (bounds.extents == Vector3.zero)
{
bounds = coll.bounds;
}
bounds.Encapsulate(coll.bounds);
}
}
}