Skip to content

A3D_GetModelBoundingBox

imshooter edited this page Oct 17, 2026 · 1 revision

Find the box that holds a model, around its position.

Models without collision, such as plants, still have the box the game gives them.

native bool:A3D_GetModelBoundingBox(
    modelid,
    &Float:minX,
    &Float:minY,
    &Float:minZ,
    &Float:maxX,
    &Float:maxY,
    &Float:maxZ
);

Parameters

Parameter Description
modelid Model to read.
&Float:minX Lowest corner on the X axis.
&Float:minY Lowest corner on the Y axis.
&Float:minZ Lowest corner on the Z axis.
&Float:maxX Highest corner on the X axis.
&Float:maxY Highest corner on the Y axis.
&Float:maxZ Highest corner on the Z axis.

Returns

  • true when the box was written.
  • false when the database does not know the model.

Remarks

The corners are offsets from the origin of the model, as if it stood at 0.0, 0.0, 0.0 without rotation. minZ is how far the model reaches under its origin, which is what a script needs to rest it on the ground.

The database knows every model of the game and the models SA-MP adds. Models with no collision, such as most plants, still have the box the game gives them.

Example

Stacks a model on top of another of the same kind.

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

    if (!A3D_GetModelBoundingBox(modelid, minX, minY, minZ, maxX, maxY, maxZ)) {
        return INVALID_OBJECT_ID;
    }

    return CreateObject(modelid, x, y, z + maxZ - minZ, 0.0, 0.0, 0.0);
}

Related

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