Hi there
I’m trying to learn about Bounds.extents at the moment and I’m having trouble trying to understand what extents are and how they are used. I know that extents are described as “the extents of the Bounding Box which is always half the size of the bounds.” I got that description from looking at the following link: Unity - Scripting API: Bounds.extents
I don’t know what this means in layman’s terms?
In order to try to understand what extents actually are I wrote the following code in a script that is attached to a quad that has a BoxCollider2D attached to it as shown here:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
Collider2D _collider2D;
public Vector2 _myScale;
// Start is called before the first frame update
void Start()
{
_collider2D = gameObject.GetComponent<Collider2D>();
//Output the GameObject's Collider Bound extents
}
// Update is called once per frame
void Update()
{
Debug.Log("extents : " + _collider2D.bounds.extents);
}
}
So when I run the code I get the extents of the Bounding Box outputted to the console. The output seems to be presented in X,Y and Z co-ordinates. If I use the “Rect Tool” while in scene view when this code is running and drag the right side of the quad towards the right the X value of the extents changes along with the X value in Scale within the Transform component of the Quad.
So are extents similar in nature to the Scale values of the Transform component? The X and Y values of the extents of the Bounding Box are basically the lengths of units that the Bounding Box occupies in world space? Would this diagram that I’ve created be correct?: Bounds-Extents hosted at ImgBB — ImgBB
