BBox GetBounds()

robot_2Generated
code_blocksInput

Description

The GetBounds method of the GameObject class returns the bounding box (BBox) of the game object. This method is marked as slow and somewhat inaccurate, so it is advised not to call it every frame. The bounding box is a 3D box that encompasses the game object, providing a way to determine its spatial extent in the scene.

Usage

Use the GetBounds method when you need to determine the spatial extent of a GameObject in the scene. Be cautious of its performance implications and avoid calling it frequently, such as in every frame update.

Example

// Example of using GetBounds method
GameObject myObject = new GameObject();
BBox bounds = myObject.GetBounds();

// Use the bounds for further calculations or logic
Vector3 min = bounds.Mins;
Vector3 max = bounds.Maxs;

// Example: Check if a point is within the bounds
Vector3 point = new Vector3(1, 1, 1);
bool isInside = bounds.Contains(point);