Skip to content

A3D_OverlapSphere

imshooter edited this page Oct 17, 2026 · 1 revision

Find everything a sphere overlaps.

native A3D_OverlapSphere(
    Float:x,
    Float:y,
    Float:z,
    Float:radius,
    A3D_HIT:types[],
    hitids[],
    size = sizeof (hitids),
    worldid = -1,
    A3D_COLLIDE:flags = A3D_COLLIDE_ALL
);

Parameters

Parameter Description Default
Float:x Centre on the X axis.
Float:y Centre on the Y axis.
Float:z Centre on the Z axis.
Float:radius Radius of the sphere.
A3D_HIT:types[] What each thing found is.
hitids[] What each thing found is, as the hitid of A3D_RayCast.
size Room in each array. sizeof (hitids)
worldid Virtual world to look in, or -1 for every world. -1
A3D_COLLIDE:flags What may be found. A3D_COLLIDE_ALL

Returns

  • The number of things written.

Remarks

Each body found is written once, in no particular order. A map object is written as its model, so two map objects of the same model both write that model. Players are found only on foot and zones never. See Hit types.

To find players, vehicles or actors near a point, A3D_GetPlayersInSphere and its siblings measure from their position and sort them by distance.

Example

Counts the physics objects within two metres of a player.

stock CountObjectsAround(playerid) {
    new
        Float:x,
        Float:y,
        Float:z,
        A3D_HIT:types[32],
        hitids[32]
    ;

    GetPlayerPos(playerid, x, y, z);

    return A3D_OverlapSphere(x, y, z, 2.0, types, hitids, .worldid = GetPlayerVirtualWorld(playerid), .flags = A3D_COLLIDE_OBJECTS);
}

Related

  • A3D_OverlapBox: Find everything a box overlaps, such as the room a vehicle or an object needs.
  • A3D_OverlapModel: Find everything a model would overlap at a position, such as before placing an object.
  • A3D_GetPlayersInSphere: Find the players within a distance of a point, nearest first.
  • A3D_CreateExplosion: Push the moving physics objects around a point away from it.

Home

Guides

Reference

Functions

Creating objects
Motion
Placement
Behaviour
Display and data
Rays
Shapes
Players, vehicles and actors
Map probes
Screen
Map objects
Water
Models and surfaces
Rotations and offsets
Vehicles
Routes
Route display
Walking
Callbacks

Clone this wiki locally