Skip to content

A3D_IsLineOfSight

imshooter edited this page Oct 17, 2026 · 1 revision

Whether nothing stands between two points.

Stops at the first thing found, so it is cheaper than A3D_RayCast.

native bool:A3D_IsLineOfSight(
    Float:x1,
    Float:y1,
    Float:z1,
    Float:x2,
    Float:y2,
    Float:z2,
    worldid = -1,
    A3D_COLLIDE:flags = A3D_COLLIDE_MAP | A3D_COLLIDE_STATIC
);

Parameters

Parameter Description Default
Float:x1 First point on the X axis.
Float:y1 First point on the Y axis.
Float:z1 First point on the Z axis.
Float:x2 Second point on the X axis.
Float:y2 Second point on the Y axis.
Float:z2 Second point on the Z axis.
worldid Virtual world to look in, or -1 for every world. -1
A3D_COLLIDE:flags What blocks the sight, the map and static objects by default. `A3D_COLLIDE_MAP

Returns

  • true when the points see each other.
  • false when something stands between them.

Remarks

Only the map and static objects block the sight by default, since a player or a vehicle in the way rarely hides someone for long. Other flags add them. With A3D_COLLIDE_WATER, the surface of the water blocks too, so a diver does not see the shore.

The query stops at the first thing it meets and skips working out the point, which makes it cheaper than A3D_RayCast.

Example

Tells whether a guard actor sees a player, from eye to eye.

stock bool:DoesGuardSee(actorid, playerid) {
    new
        Float:guardX,
        Float:guardY,
        Float:guardZ,
        Float:x,
        Float:y,
        Float:z
    ;

    GetActorPos(actorid, guardX, guardY, guardZ);
    GetPlayerPos(playerid, x, y, z);

    return A3D_IsLineOfSight(guardX, guardY, guardZ + 0.7, x, y, z + 0.7, GetPlayerVirtualWorld(playerid));
}

Related

  • A3D_RayCast: Find the first thing a segment between two points hits.
  • A3D_GetPlayersInCone: Find the players inside a cone, such as the view of a guard or the spread of a shotgun, nearest first.
  • A3D_IsPointOnScreen: Whether a point shows on the screen of a player.

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