- Home /
Why is a collider's size different from its bounds.size?
I am printing out a box collider's size (collider.size), and its bounds size (collider.bounds.size). They give me two distinct values:
"=> (0.6, 0.4, 0.5) vs (0.4, 0.4, 0.4)"
I have made sure that the object is not in some strange transform or anything (since I know the collider.size is represented in local space). I have also tried converting the collider.size to world space and still the same discrepancy. Is this known/expected? Is the collider's bounds more liberal on purpose?
Answer by rutter · Dec 15, 2013 at 01:41 AM
A BoxCollider's size is expressed in local space; its bounds are an axis-aligned bounding box (or "AABB") expressed in world space. If your box is scaled or rotated, the two values will not necessarily agree.
As you might infer from the above, an object's AABB will always be at least as large as its actual size.
Answer by singhlaxman9761 · Apr 09, 2021 at 05:34 AM
BoxCollider2D collider.bound.size is change when your are scale or rotate game object it will change the bund size value. In collider.size is depends on only size value shown in inspector.
Your answer
Follow this Question
Related Questions
Positioning gameobject on collider bounds. 1 Answer
bound.Intersects returning true when false 1 Answer
Matching an object's size 1 Answer
Internal collisions 1 Answer
How to check if a point is in a rotated BoxCollider? 2 Answers