codeAPI Reference

Sandbox.BBox

calendar_today May 3, 2026 schedule ~1 min read person patrickjr verified 50

Sandbox.BBox

Axis-aligned bounding box.

Overview

BBox represents an axis-aligned box in 3D space. Used for collision, bounds checking, and spatial queries.

Creation

CSHARP
// From min/max corners
BBox box = new BBox(minPos, maxPos);

// From center and extents
BBox box = BBox.FromPositionAndExtents(center, extents);

// From points
BBox box = BBox.FromPoints(points);

// From position and size
BBox box = BBox.FromPositionAndSize(pos, size);

Properties

PropertyDescription
MinsMinimum corner
MaxsMaximum corner
CenterCenter point
ExtentsHalf-size (distance from center to edge)
SizeFull size
VolumeVolume in cubic units

Operations

CSHARP
// Add point (expands to include)
box = box.AddPoint(point);

// Add box
box = box.AddBox(other);

// Translate
box = box.Translate(offset);

// Scale
box = box.Scale(scale);

// Rotate (becomes bigger to stay axis-aligned)
box = box.Rotate(rotation);

Containment

CSHARP
// Check point inside
bool inside = box.Contains(point);

// Check box inside
bool contains = box.Contains(otherBox);

// Check intersects
bool intersects = box.Intersects(otherBox);

Distance

CSHARP
// Distance from point to box
float dist = box.Distance(point);

// Distance squared
float distSq = box.DistanceSquared(point);

Corners

CSHARP
// Get all 8 corners
Vector3[] corners = box.Corners;

// Specific corner
Vector3 frontLeftBottom = box.Mins;
Vector3 backRightTop = box.Maxs;

Usage

CSHARP
// Object bounds
BBox bounds = renderer.Model.Bounds;

// Hitbox
BBox hitbox = new BBox(WorldPosition - 50, WorldPosition + 50);

// Spatial query
var nearby = Scene.FindAllInBox(box);
Was this helpful?