Skip to content

A3D_FindGround

imshooter edited this page Oct 17, 2026 · 1 revision

Find the ground under a point.

Looks down from the point, so under a bridge or inside a building it finds the floor below and not the roof above.

native bool:A3D_FindGround(
    Float:x,
    Float:y,
    Float:z,
    &Float:groundZ,
    worldid = -1,
    A3D_COLLIDE:flags = A3D_COLLIDE_MAP | A3D_COLLIDE_STATIC,
    Float:depth = 1000.0
);

Parameters

Parameter Description Default
Float:x Point on the X axis.
Float:y Point on the Y axis.
Float:z Point on the Z axis, where the search starts.
&Float:groundZ Height of the ground.
worldid Virtual world to look in, or -1 for every world. -1
A3D_COLLIDE:flags What counts as ground, the map and static objects by default. `A3D_COLLIDE_MAP
Float:depth How far down to look. 1000.0

Returns

  • true when the ground was found.
  • false when nothing lies below within depth.

Remarks

The search goes straight down from the point, so start it a little above where the ground is expected, such as the position of a player. A search from high in the sky finds roofs, bridges and the interiors the game places in the sky before the ground.

CA_FindZ_For2DCoord of ColAndreas looks from a height of 700.0 down to -1000.0. The same search here is a point at 700.0 with a depth of 1700.0 and A3D_COLLIDE_MAP as the flags.

Example

Drops an object on the floor under a player, resting on its lowest point.

stock DropModel(playerid, modelid) {
    new
        Float:x,
        Float:y,
        Float:z,
        Float:groundZ,
        Float:minX,
        Float:minY,
        Float:minZ,
        Float:maxX,
        Float:maxY,
        Float:maxZ
    ;

    GetPlayerPos(playerid, x, y, z);

    if (!A3D_FindGround(x, y, z, groundZ, GetPlayerVirtualWorld(playerid))) {
        return INVALID_OBJECT_ID;
    }

    A3D_GetModelBoundingBox(modelid, minX, minY, minZ, maxX, maxY, maxZ);

    return CreateObject(modelid, x, y, groundZ - minZ, 0.0, 0.0, 0.0);
}

Related

  • A3D_RayCast: Find the first thing a segment between two points hits.
  • A3D_FindRandomPoint: Find a random spot on the ground around a point where something fits, such as a spawn or a dropped item.
  • A3D_GetModelBoundingBox: Find the box that holds a model, around its position.

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