Bounds
An axis-aligned bounding box. It acts as a simple container for a center position and the extents (further subdivided into size, min, max) of a box that can be used for collision detection, visibility testing, or other similar tasks in your game.
Properties
Vector3 value that signifies the central point of the bounding box.
The size of the bounding box for each dimension - how wide, tall, and deep it is.
Similar to size but it represents half the size of the bounding box in each dimension. This can be used when you need to measure from the center of the bounding box.
The minimum value (lower-left-front corner) of the bounding box coordinates.
The maximal value (upper-right-back corner) of the bounding box coordinates.
Methods
The minimum and maximum corners of the bounding box.
Grows the Bounds to include a point or bounds. You would typically use this when you have a set of points and you want a bounding box that encloses all these points.
Parameters
point
Vector3The new point to include within the bounding box.
Returns
Increases the size of the bounding box by the given amount (in both directions).
Parameters
amount
The amount by which the bounding box should be expanded (shrank if negative).
Returns
Checks whether the current bounding box intersects with another bounding box. You can use this to determine if two objects are likely to be colliding.
Parameters
bounds
BoundsThe other bounding box to test intersection with.
Returns
Returns true if the bounding boxes intersect, false otherwise.
Determines if a specified Ray intersects the bounds. This can prove vital in various game scenarios for interaction detection such as determining if a projectile is in range of an object or if a click or tap in screen space intersects a game object. It evaluates the intersection and returns true if the Ray intersects with the bounds, otherwise it returns false.
Parameters
ray
RayThe Ray instance against which the intersection is to be checked.
Returns
Returns true if the Ray intersects with the bounds, otherwise false.
Check whether a specific point is within the current bounding box.
Parameters
point
Vector3This is the point which you want to check.
Returns
Returns true if the point is inside the bounding box, false otherwise.
Returns the squared distance from a point to the bounding box. Squared distances can be useful for comparison without needing the computationally expensive square root operation.
Parameters
point
Vector3The point from which the distance is measured.
Returns
Returns the squared distance from the bounding box to the point.
The closest point on or inside the bounding box to a given point. This can be helpful in figuring out how close an object is to entering a bounding box.