World:queryBox
EditFind 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
Name | Type | Default | Description |
x | number | The x coordinate of the center of the box, in meters. | |
y | number | The y coordinate of the center of the box, in meters. | |
z | number | The z coordinate of the center of the box, in meters. | |
width | number | The width of the box, in meters | |
height | number | The height of the box, in meters | |
depth | number | The depth of the box, in meters. | |
filter | string | nil |
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.
|
callback | function |
A function to call when a collider is detected. The function will be called with a single Collider argument.
|
Returns
Nothing
Arguments
Name | Type | Default | Description |
position | Vec3 | The position of the center of the box, in meters. | |
size | Vec3 | The size of the box, in meters. | |
filter | string | nil |
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.
|
callback | function |
A function to call when a collider is detected. The function will be called with a single Collider argument.
|
Returns
Nothing
Arguments
Name | Type | Default | Description |
x | number | The x coordinate of the center of the box, in meters. | |
y | number | The y coordinate of the center of the box, in meters. | |
z | number | The z coordinate of the center of the box, in meters. | |
width | number | The width of the box, in meters | |
height | number | The height of the box, in meters | |
depth | number | The depth of the box, in meters. | |
filter | string | nil |
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
Name | Type | Description |
collider | Collider | A Collider that intersected the box. |
Arguments
Name | Type | Default | Description |
position | Vec3 | The position of the center of the box, in meters. | |
size | Vec3 | The size of the box, in meters. | |
filter | string | nil |
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
Name | Type | Description |
collider | Collider | A Collider that intersected the box. |
Notes
This will return sleeping colliders and sensors, but it will ignore disabled colliders.