Skip to content

A3D_CreateBox

imshooter edited this page Oct 18, 2026 · 2 revisions

Create a moving physics object shaped like a box.

native Physic:A3D_CreateBox(
    modelid,
    Float:sizeX,
    Float:sizeY,
    Float:sizeZ,
    Float:x,
    Float:y,
    Float:z,
    Float:rx = 0.0,
    Float:ry = 0.0,
    Float:rz = 0.0,
    Float:mass = 1.0,
    worldid = -1
);

Parameters

Parameter Description Default
modelid Model shown, or -1 for none.
Float:sizeX Size on the X axis.
Float:sizeY Size on the Y axis.
Float:sizeZ Size on the Z axis.
Float:x Position on the X axis.
Float:y Position on the Y axis.
Float:z Position on the Z axis.
Float:rx Rotation on the X axis. 0.0
Float:ry Rotation on the Y axis. 0.0
Float:rz Rotation on the Z axis. 0.0
Float:mass Mass in kilograms. 1.0
worldid Virtual world it collides in, or -1 for every world. -1

Returns

  • The physics object.
  • INVALID_PHYSIC_ID when a size is not positive, or the world is full.

Remarks

The sizes are full lengths along the axes of the box, not half lengths. The box is centred on the position, while a model is drawn around its own origin. A model whose collision is not centred on its origin, such as one with its origin at the bottom, fits better with A3D_CreateObject.

A box is cheaper than a model shaped object and slides and tips over like one. The surface of a box is 0. Everything else follows A3D_CreateObject.

Example

Creates a box the size of a model, from the box the game gives it.

stock Physic:CreateModelBox(modelid, Float:x, Float:y, Float:z, Float:angle, Float:mass) {
    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_PHYSIC_ID;
    }

    return A3D_CreateBox(modelid, maxX - minX, maxY - minY, maxZ - minZ, x, y, z, 0.0, 0.0, angle, mass);
}

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