Builtin Library
README.md
carry
The colliders a character carries: the one on its own entity and the ones on every entity parented under it, such as a held prop, a weapon or a trigger volume that travels with the character. A carried collider moves with the body, so it is never ground the body stands on, a ceiling it bumps, or a wall it walks into. The ground, ceiling and wall passes of the character controller all ask their questions through this module. No state.
Exports
M.carriedBy(entityId: string, selfId: string) -> boolean: whether the collider onentityIdis one the bodyselfIdcarries:selfIditself or an entity parented under it at any depth. An emptyselfIdcarries nothing.M.raycast(origin: Vec3, dir: Vec3, maxDist: number, selfId: string) -> hit?: cast a ray and return the first surface it meets that the body does not carry, passing through every carried collider on the way. Returns the raycast hit table{ entityId, point, normal, distance, startedInside }ornil.
Usage
local Carry = require("@builtin::systems.characterController.characterController.physics.carry")
-- The ground under a character, whatever it holds at its feet.
local hit = Carry.raycast({ x = px, y = py + 0.3, z = pz }, { x = 0, y = -1, z = 0 }, 0.5, selfId)
-- A sweep that skips what the body carries.
if not Carry.carriedBy(sweepHit.entityId, selfId) then
-- a wall
end