Skip to content

A3D_CreateSphere

imshooter edited this page Oct 18, 2026 · 2 revisions

Create a moving physics object shaped like a sphere.

native Physic:A3D_CreateSphere(
    modelid,
    Float:radius,
    Float:x,
    Float:y,
    Float:z,
    Float:mass = 1.0,
    worldid = -1
);

Parameters

Parameter Description Default
modelid Model shown, or -1 for none.
Float:radius Radius of the sphere.
Float:x Position on the X axis.
Float:y Position on the Y axis.
Float:z Position on the Z axis.
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 the radius is not positive, or the world is full.

Remarks

A sphere is the cheapest body and the only one that rolls without wobbling. It suits balls, stones and anything round. The model only decides what players see, so its size should match the radius. A3D_GetModelBoundingSphere gives the radius of a model.

A model of -1 shows nothing. Such a sphere still moves, collides and calls its callbacks, which makes it a probe or a body for a streamer object given with A3D_AttachDynamicObject.

The surface of a sphere is 0, the surface DEFAULT. Everything else follows A3D_CreateObject.

Example

Throws a beach ball where the camera of the player looks.

stock Physic:ThrowBeachBall(playerid) {
    new
        Float:x,
        Float:y,
        Float:z,
        Float:frontX,
        Float:frontY,
        Float:frontZ,
        Physic:ball
    ;

    GetPlayerPos(playerid, x, y, z);
    GetPlayerCameraFrontVector(playerid, frontX, frontY, frontZ);
    ball = A3D_CreateSphere(1598, 0.3, x + frontX, y + frontY, z + 0.6, 0.5, GetPlayerVirtualWorld(playerid));

    if (ball == INVALID_PHYSIC_ID) {
        return INVALID_PHYSIC_ID;
    }

    A3D_SetBounce(ball, 0.8);
    A3D_SetVelocity(ball, frontX * 12.0, frontY * 12.0, frontZ * 12.0 + 2.0);

    return ball;
}

Related

  • A3D_CreateObject: Create a moving physics object shaped like the collision of a model, or as models.json describes the model.
  • A3D_CreateBox: Create a moving physics object shaped like a box.
  • A3D_GetModelBoundingSphere: Find the sphere that holds a model, around its position.
  • A3D_SetVelocity: Set the velocity of a moving physics object and wake it up.
  • A3D_SetRollingFriction: Slow a moving physics object down by a constant amount, as a ball rolling on cloth.

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