Find colliders within a sphere. 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 sphere.
y
number
The y coordinate of the center of the sphere.
z
number
The z coordinate of the center of the sphere.
radius
number
The radius of the sphere, 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 an intersection is detected. The function will be called with a single Collider argument.
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 an intersection 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 sphere.
y
number
The y coordinate of the center of the sphere.
z
number
The z coordinate of the center of the sphere.
radius
number
The radius of the sphere, 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.
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.