- Home /
Question by
egonspengler_84 · Apr 08, 2021 at 11:29 PM ·
sizeboundsboundingbox
Is the bounds.size and the GetComponent.BoxCollider2D.size of a GameObject meant to be the same?
I have a script attached to a GameObject with the following code:
public class Player: MonoBehaviour{
private BoxCollider2D _col2D;
void Start(){
_col2D = GetComponent<BoxCollider2D>();
}
void Update(){
Debug.Log("The size of the Bounding Box equals: " + _col2D.bounds.size);
Debug.Log("The size of the BoxCollider2D equals: " +_col2D.size);
}
I would have thought that "_col2D.bounds.size" and "_col2D.size" would output the exact same thing however when I run this code it outputs the following to the console:
Size of Player's BoxCollider2D component is(5.2, 8.4)
Size of Player's Bounding Box is(1.6, 2.6, 0.0)
Could someone help me why the Vector values of these two things are different?
Comment
Answer by singhlaxman9761 · Apr 09, 2021 at 05:33 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.