BoxCollider3d

Extends: Collider

A collider with the shape of a box CENTERED at (offset.x, offset.y, offset.z), with given width (x), height (y), depth (z), axis-aligned unless turned by yaw. 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 of unturned boxes that passes both plane checks is always a genuine 3D overlap, and confirmCollision() runs aabbOverlap() only for the penetration/normal result. A turned box's broad phase uses the axis-aligned box around it, so confirmCollision() then does reject (orientedBoxOverlap()/sphereOrientedBoxOverlap()). 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)
  • yaw (float) — Turn about the y axis through the box's centre, in radians, the same way GameEntity.rotation.y
  • 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

getWorldBounds( entityPosition: BGE.Math.Vector, out: Array.<float>, ): boolean

Parameters

  • entityPosition (BGE.Math.Vector)
  • out (Array.<float>)

Returns

  • boolean

disableCollisionChecking(): void

Returns

  • void

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

Parameters

  • entityPosition (BGE.Math.Vector)

Returns

  • void

removeFromCompositor(): void

Returns

  • void

debugDraw( renderObj: Renderer, position: BGE.Math.Vector, color?: integer, addName?: boolean, font?: roFont, ): void

Parameters

  • renderObj (Renderer)
  • position (BGE.Math.Vector)
  • color (integer, optional, default: "&hFF0000FF")
  • addName (boolean, optional, default: false)
  • font (roFont, optional, default: "invalid")

Returns

  • void