Skip to content

A3D_GetModelPhysics

imshooter edited this page Oct 18, 2026 · 2 revisions

Find how the game moves a model that can be knocked over, such as a bin or a crate, in the values the natives of this include take.

The values come from object.dat. The buoyancy is 100.0 over the share of the object the game keeps under water, and the damping matches the air resistance of the game at 50 frames a second.

native bool:A3D_GetModelPhysics(
    modelid,
    &Float:mass,
    &Float:bounce,
    &Float:buoyancy,
    &Float:damping
);

Parameters

Parameter Description
modelid Model to read.
&Float:mass Mass in kilograms, for A3D_CreateObject.
&Float:bounce Bounce, for A3D_SetBounce.
&Float:buoyancy Buoyancy, for A3D_SetBuoyancy.
&Float:damping Loss of speed, for the linear value of A3D_SetDamping.

Returns

  • true when the values were written.
  • false when the game never moves the model, or the database has no such data.

Remarks

Only the 826 models of object.dat have this data, the bins, crates, cones, barrels and other objects the game lets players knock over. The values are converted to what the natives of the include take:

Value From object.dat
mass The mass, unchanged.
bounce The elasticity, unchanged.
buoyancy 100.0 divided by the share of the object the game keeps under water.
damping The air resistance, turned into a loss of speed per second at the 50 frames a second of the game.

Some values of the game are odd. The beach ball weighs 1,000 kilograms and several objects that should never move weigh 99,999. Check the mass before using it.

Example

Creates an object that moves as the game moves it.

stock Physic:CreateGameObject(modelid, Float:x, Float:y, Float:z) {
    new
        Float:mass,
        Float:bounce,
        Float:buoyancy,
        Float:damping,
        Physic:physicid
    ;

    if (!A3D_GetModelPhysics(modelid, mass, bounce, buoyancy, damping)) {
        return A3D_CreateObject(modelid, x, y, z);
    }

    physicid = A3D_CreateObject(modelid, x, y, z, 0.0, 0.0, 0.0, mass);
    A3D_SetBounce(physicid, bounce);
    A3D_SetBuoyancy(physicid, buoyancy);
    A3D_SetDamping(physicid, damping, 0.3);

    return physicid;
}

Related

  • A3D_CreateObject: Create a moving physics object shaped like the collision of a model, or as models.json describes the model.
  • A3D_SetBounce: Set how much a physics object bounces.
  • A3D_SetBuoyancy: Make a moving physics object float in the water of the map.
  • A3D_SetDamping: Set how fast a moving physics object loses speed and spin on its own.

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