Skip to content

A3D_RayCastAll

imshooter edited this page Oct 17, 2026 · 1 revision

Find everything a segment hits, nearest first.

A model the segment goes through is hit where it enters and where it leaves.

native A3D_RayCastAll(
    Float:startX,
    Float:startY,
    Float:startZ,
    Float:endX,
    Float:endY,
    Float:endZ,
    Float:x[],
    Float:y[],
    Float:z[],
    A3D_HIT:types[],
    hitids[],
    materials[],
    size = sizeof (x),
    worldid = -1,
    A3D_COLLIDE:flags = A3D_COLLIDE_ALL
);

Parameters

Parameter Description Default
Float:startX Start of the segment on the X axis.
Float:startY Start on the Y axis.
Float:startZ Start on the Z axis.
Float:endX End of the segment on the X axis.
Float:endY End on the Y axis.
Float:endZ End on the Z axis.
Float:x[] Points hit on the X axis.
Float:y[] Points hit on the Y axis.
Float:z[] Points hit on the Z axis.
A3D_HIT:types[] What each point hit.
hitids[] What each point hit, as the hitid of A3D_RayCast.
materials[] Surface of the game at each point.
size Room in each array. sizeof (x)
worldid Virtual world to look in, or -1 for every world. -1
A3D_COLLIDE:flags What the segment may hit. A3D_COLLIDE_ALL

Returns

  • The number of points written.

Remarks

Every hit along the segment is written, nearest first, until the arrays are full. A model the segment passes through gives two hits, one where it enters and one where it leaves. With A3D_COLLIDE_WATER, the place where the segment crosses the water is one of the hits.

The return value counts the hits written, so a full array may mean that more hits were left out. The six arrays must hold size cells each.

Example

Counts the walls of the map between two points, as a shot that goes through them would.

stock CountWalls(Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2) {
    new
        Float:x[16],
        Float:y[16],
        Float:z[16],
        A3D_HIT:types[16],
        hitids[16],
        materials[16],
        count = A3D_RayCastAll(x1, y1, z1, x2, y2, z2, x, y, z, types, hitids, materials, .flags = A3D_COLLIDE_MAP)
    ;

    return (count + 1) / 2;
}

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