Skip to content

A3D_SetBuoyancy

imshooter edited this page Oct 17, 2026 · 1 revision

Make a moving physics object float in the water of the map.

Without it, objects sink like stones. An object floats with 1.0 / buoyancy of its volume under the surface: 2.0 floats half under, 1.0 stays at any depth, and less sinks slowly. While it touches the water it loses drag of its speed each second, so it settles and rests. A3D_GetModelPhysics gives the buoyancy the game uses for a model.

native bool:A3D_SetBuoyancy(Physic:physicid, Float:buoyancy, Float:drag = 1.0);

Parameters

Parameter Description Default
Physic:physicid Physics object to change.
Float:buoyancy How much it floats, or 0.0 to stop it floating.
Float:drag Share of its speed the water takes each second. 1.0

Returns

  • true when the buoyancy was set.
  • false when physicid is not a moving physics object, or a value is negative.

Remarks

The water is that of the map database. With a ColAndreas database there is no water and nothing floats.

The push of the water acts on the part of the object under the surface, so an object bobs and settles at the depth its buoyancy gives. A buoyancy of 2.0 floats with half of the object under the surface and 4.0 with a quarter. While the object touches the water, drag takes that share of its speed every second, so it calms down and comes to rest.

The water of an interior placed above the city pushes only objects that are in it, with nothing of the map between them and its surface.

Example

Throws a crate into the sea that floats as in the game.

stock Physic:ThrowCrate(Float:x, Float:y, Float:z) {
    new
        Float:mass,
        Float:bounce,
        Float:buoyancy,
        Float:damping,
        Physic:crate
    ;

    A3D_GetModelPhysics(1271, mass, bounce, buoyancy, damping);
    crate = A3D_CreateObject(1271, x, y, z, 0.0, 0.0, 0.0, mass);
    A3D_SetBuoyancy(crate, buoyancy);
    A3D_SetVelocity(crate, 0.0, 6.0, 3.0);

    return crate;
}

Related

  • A3D_GetModelPhysics: 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.
  • A3D_GetWaterLevel: Find the height of the water at a point of the map.
  • A3D_IsPointInWater: Whether a point lies 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
Callbacks

Clone this wiki locally