Skip to content

A3D_RayCastNormal

imshooter edited this page Oct 17, 2026 · 1 revision

Find the first thing a segment hits, and the direction its surface faces there.

The normal points towards the start of the segment. A flat floor gives 0.0, 0.0, 1.0.

native bool:A3D_RayCastNormal(
    Float:startX,
    Float:startY,
    Float:startZ,
    Float:endX,
    Float:endY,
    Float:endZ,
    &Float:x,
    &Float:y,
    &Float:z,
    &Float:normalX,
    &Float:normalY,
    &Float:normalZ,
    &A3D_HIT:type = A3D_HIT_MAP,
    &hitid = 0,
    &material = 0,
    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 Point hit on the X axis.
&Float:y Point hit on the Y axis.
&Float:z Point hit on the Z axis.
&Float:normalX Normal of the surface on the X axis.
&Float:normalY Normal on the Y axis.
&Float:normalZ Normal on the Z axis.
&A3D_HIT:type What was hit. A3D_HIT_MAP
&hitid Model of the map object, or the physics object, static object, player, vehicle or actor hit. 0
&material Surface of the game hit, see A3D_GetMaterialName. 0
worldid Virtual world to look in, or -1 for every world. -1
A3D_COLLIDE:flags What the segment may hit. A3D_COLLIDE_ALL

Returns

  • true when something was hit.
  • false when the segment is clear.

Remarks

The normal is one metre long and faces the start of the segment, whichever side of the face was hit. A floor gives 0.0, 0.0, 1.0 and a wall a normal with no Z part. The water gives 0.0, 0.0, 1.0, or -1.0 for a ray that goes up into it.

Everything else follows A3D_RayCast.

Example

Tells whether the ground under a player is too steep to stand on.

stock bool:IsOnSteepGround(playerid) {
    new
        Float:x,
        Float:y,
        Float:z,
        Float:hitX,
        Float:hitY,
        Float:hitZ,
        Float:normalX,
        Float:normalY,
        Float:normalZ
    ;

    GetPlayerPos(playerid, x, y, z);

    if (!A3D_RayCastNormal(x, y, z, x, y, z - 3.0, hitX, hitY, hitZ, normalX, normalY, normalZ, .flags = A3D_COLLIDE_MAP)) {
        return false;
    }

    return normalZ < 0.7;
}

Related

  • A3D_RayCast: Find the first thing a segment between two points hits.
  • A3D_GetSurfaceRotation: Find the rotation that stands an object on a surface, such as a crate on a slope.
  • A3D_GetReflection: Find the direction something takes after bouncing off a surface, such as a bullet that ricochets.

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