I want to make a system that automatically detects how big my world bounds need to be, by measuring the most extreme point of the colliders in my world. The only colliders i currently have are one BoxCollider2D
(trigger), one TilemapCollider2D
and one CompositeCollider2D
on the same object. However, the following code:
foreach (Collider2D c in World.GetComponentsInChildren<Collider2D>())
{
Bounds b = c.bounds;
Debug.Log("Bounds: " + b.max + ", " + b.min);
}
logs (0, 0, 0), (0, 0, 0)
for the tilemap and composite colliders and the position of the box collider.
I have no idea why it’s happening, in the scene view when i check the BoxCollider2D
it displays different bounds in the info box even.
Thanks for your time!
Edit:
I realize now that the problem may have something to do with the fact that the colliders are part of a prefab, and not an active game object. The script is run in from the inspector.
Also, does anyone know how to add line breaks when asking a question?