Skip to content

A3D_GetVehiclePositionOffset

imshooter edited this page Oct 17, 2026 · 1 revision

Find where a point of the world lies relative to a vehicle, such as whether a player stands behind it.

native bool:A3D_GetVehiclePositionOffset(
    vehicleid,
    Float:x,
    Float:y,
    Float:z,
    &Float:offsetX,
    &Float:offsetY,
    &Float:offsetZ
);

Parameters

Parameter Description
vehicleid Vehicle to measure from.
Float:x Point in the world on the X axis.
Float:y Point on the Y axis.
Float:z Point on the Z axis.
&Float:offsetX Offset along the X axis of the vehicle, positive to its right.
&Float:offsetY Offset along its Y axis, positive to its front.
&Float:offsetZ Offset along its Z axis, positive up.

Returns

  • true when the offset was written.
  • false when there is no such vehicle.

Remarks

The reverse of A3D_GetVehicleOffsetPosition. The sign of each part tells the side: a negative Y lies behind the centre and a negative X to the left.

Example

Tells whether a player stands behind a vehicle, close to it.

stock bool:IsBehindVehicle(playerid, vehicleid) {
    new
        Float:x,
        Float:y,
        Float:z,
        Float:offsetX,
        Float:offsetY,
        Float:offsetZ,
        Float:sizeX,
        Float:sizeY,
        Float:sizeZ
    ;

    GetPlayerPos(playerid, x, y, z);

    if (!A3D_GetVehiclePositionOffset(vehicleid, x, y, z, offsetX, offsetY, offsetZ)) {
        return false;
    }

    GetVehicleModelInfo(GetVehicleModel(vehicleid), VEHICLE_MODEL_INFO_SIZE, sizeX, sizeY, sizeZ);

    return offsetY < -sizeY / 2.0 && offsetY > -sizeY / 2.0 - 1.5 && floatabs(offsetX) < sizeX / 2.0;
}

Related

  • A3D_GetVehicleOffsetPosition: Find where a point given relative to a vehicle lies in the world, as the vehicle stands and leans now.
  • A3D_GetPositionOffset: Find where a point of the world lies relative to an object, the reverse of A3D_GetOffsetPosition.

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