World:queryBox

Edit

Find colliders within an axis-aligned bounding box. This is a fast but imprecise query that only checks a rough box around colliders. Use World:overlapShape for an exact collision test.

Rough queries like this are useful for doing a quick check before doing lots of more expensive collision testing.

Pass a callback function to call for each collider detected, or leave the callback off and this function will return the first collider found.





Arguments

NameTypeDefaultDescription
xnumber The x coordinate of the center of the box, in meters.
ynumber The y coordinate of the center of the box, in meters.
znumber The z coordinate of the center of the box, in meters.
widthnumber The width of the box, in meters
heightnumber The height of the box, in meters
depthnumber The depth of the box, in meters.
filterstringnil An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put ~ in front of the tags to exclude colliders with those tags.
callbackfunction A function to call when a collider is detected. The function will be called with a single Collider argument.

Returns

Nothing

Arguments

NameTypeDefaultDescription
positionVec3 The position of the center of the box, in meters.
sizeVec3 The size of the box, in meters.
filterstringnil An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put ~ in front of the tags to exclude colliders with those tags.
callbackfunction A function to call when a collider is detected. The function will be called with a single Collider argument.

Returns

Nothing

Arguments

NameTypeDefaultDescription
xnumber The x coordinate of the center of the box, in meters.
ynumber The y coordinate of the center of the box, in meters.
znumber The z coordinate of the center of the box, in meters.
widthnumber The width of the box, in meters
heightnumber The height of the box, in meters
depthnumber The depth of the box, in meters.
filterstringnil An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put ~ in front of the tags to exclude colliders with those tags.

Returns

NameTypeDescription
colliderCollider A Collider that intersected the box.

Arguments

NameTypeDefaultDescription
positionVec3 The position of the center of the box, in meters.
sizeVec3 The size of the box, in meters.
filterstringnil An optional tag filter. Pass one or more tags separated by spaces to only return colliders with those tags. Or, put ~ in front of the tags to exclude colliders with those tags.

Returns

NameTypeDescription
colliderCollider A Collider that intersected the box.

Notes

This will return sleeping colliders and sensors, but it will ignore disabled colliders.

See also