Skip to content

A3D_SetVelocity

imshooter edited this page Oct 17, 2026 · 1 revision

Set the velocity of a moving physics object and wake it up.

native bool:A3D_SetVelocity(Physic:physicid, Float:vx, Float:vy, Float:vz);

Parameters

Parameter Description
Physic:physicid Physics object to push.
Float:vx Velocity on the X axis, in metres per second.
Float:vy Velocity on the Y axis, in metres per second.
Float:vz Velocity on the Z axis, in metres per second.

Returns

  • true when the velocity was set.
  • false when physicid is not a moving physics object.

Remarks

The velocity replaces the one the object had, whatever its mass. The spin is kept. To push by an amount that depends on the mass, use A3D_ApplyImpulse.

Example

Kicks a ball away from a player, along the ground and a little up.

stock KickBall(playerid, Physic:ball, Float:speed) {
    new
        Float:x,
        Float:y,
        Float:z,
        Float:ballX,
        Float:ballY,
        Float:ballZ,
        Float:distance
    ;

    GetPlayerPos(playerid, x, y, z);

    if (!A3D_GetPosition(ball, ballX, ballY, ballZ)) {
        return;
    }

    distance = VectorSize(ballX - x, ballY - y, 0.0);

    if (distance == 0.0) {
        return;
    }

    A3D_SetVelocity(ball, (ballX - x) / distance * speed, (ballY - y) / distance * speed, speed * 0.3);
}

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