Skip to content

A3D_GetLookRotation

imshooter edited this page Oct 17, 2026 · 1 revision

Find the rotation that turns the front of an object, its Y axis, to a point, such as a camera or a turret.

native bool:A3D_GetLookRotation(
    Float:x,
    Float:y,
    Float:z,
    Float:targetX,
    Float:targetY,
    Float:targetZ,
    &Float:rx,
    &Float:ry,
    &Float:rz
);

Parameters

Parameter Description
Float:x Position of the object on the X axis.
Float:y Position on the Y axis.
Float:z Position on the Z axis.
Float:targetX Point to face on the X axis.
Float:targetY Point on the Y axis.
Float:targetZ Point on the Z axis.
&Float:rx Rotation on the X axis.
&Float:ry Rotation on the Y axis.
&Float:rz Rotation on the Z axis.

Returns

  • true when the rotation was written.
  • false when both points are the same.

Remarks

The front of an object is its Y axis, the way it faces with no rotation. The result tilts the front up or down to the point and then turns it to the heading of the point, with no roll, as a camera on a stand turns.

Example

A security camera that follows a player.

forward @Camera_Follow(objectid, playerid);
public @Camera_Follow(objectid, playerid) {
    new
        Float:x,
        Float:y,
        Float:z,
        Float:cameraX,
        Float:cameraY,
        Float:cameraZ,
        Float:rx,
        Float:ry,
        Float:rz
    ;

    GetPlayerPos(playerid, x, y, z);
    GetObjectPos(objectid, cameraX, cameraY, cameraZ);

    if (A3D_GetLookRotation(cameraX, cameraY, cameraZ, x, y, z, rx, ry, rz)) {
        SetObjectRot(objectid, rx, ry, rz);
    }

    return 1;
}

Related

  • A3D_GetSurfaceRotation: Find the rotation that stands an object on a surface, such as a crate on a slope.
  • A3D_GetOffsetRotation: Find the rotation in the world of something turned relative to an object, such as an object attached to another.

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