BoxCollider3d

Extends: Collider

A collider with the shape of an axis-aligned box CENTERED at (offset.x, offset.y, offset.z), with given width (x), height (y), depth (z). Note this offset convention is center-based, not RectangleCollider's own corner-based convention (see RectangleCollider's class doc) - deliberately simpler, since BoxCollider3d's own 3D math (aabbOverlap()) has no reason to inherit RectangleCollider's screen-space corner convention.

Internally, this owns two ordinary RectangleColliders for broad-phase - one tracking the entity's real (x, y) plane, one tracking a synthetic (y, z) "YZ plane", flagged with COLLIDER_3D_YZ_PLANE_FLAG the same way SphereCollider3d's internal colliders are (see that class's doc comment for why). Unlike SphereCollider3d, this two-plane broad phase has NO false-positive case for boxes - AABB overlap decomposes exactly per axis, so a pair that passes both plane checks is always a genuine 3D overlap. confirmCollision() still runs aabbOverlap(), but only to compute the penetration/normal result for physics response, not to reject anything. See specs/2026-09-18-3d-collision-detection-design.md.

Properties

  • width (float) — Full extent of the box along each axis (this is a full width/height/depth, not a half-extent)
  • height (float)
  • depth (float)
  • lastCollisionResult (Box3dCollisionResult) — The most recent confirmCollision() result, readable from onCollision() to compute a

Constructor

new BoxCollider3d( colliderName: string, args?: roAssociativeArray, ): BoxCollider3d

Create a new BoxCollider3d

Parameters

  • colliderName (string) — name of this collider
  • args (roAssociativeArray, optional, default: "{}") — additional properties (e.g {width: 10, height: 20, depth: 10})

Instance Methods

setupCompositor( gameEngine: Game, entityName: string, entityId: string, entityPosition: BGE.Math.Vector, ): void

Parameters

  • gameEngine (Game)
  • entityName (string)
  • entityId (string)
  • entityPosition (BGE.Math.Vector)

Returns

  • void

checkCollisions(entityPosition: BGE.Math.Vector): Array.<object>

Parameters

  • entityPosition (BGE.Math.Vector)

Returns

  • Array.<object>

confirmCollision( myEntity: object, otherCollider: Collider, otherEntity: object, ): boolean

Parameters

  • myEntity (object)
  • otherCollider (Collider)
  • otherEntity (object)

Returns

  • boolean

raycastCheck( entityPosition: BGE.Math.Vector, rayOrigin: BGE.Math.Vector, rayDirection: BGE.Math.Vector, maxDistance: float, ): BGE.RaycastHit

Parameters

  • entityPosition (BGE.Math.Vector)
  • rayOrigin (BGE.Math.Vector)
  • rayDirection (BGE.Math.Vector)
  • maxDistance (float)

Returns

disableCollisionChecking(): void

Returns

  • void

adjustCompositorObject(entityPosition: BGE.Math.Vector): void

Parameters

  • entityPosition (BGE.Math.Vector)

Returns

  • void

removeFromCompositor(): void

Returns

  • void