Skip to content

A3D_OnCollided

imshooter edited this page Oct 17, 2026 · 1 revision

A moving physics object hit something faster than its collision speed.

public A3D_OnCollided(Physic:physicid, A3D_HIT:type, hitid, Float:x, Float:y, Float:z, Float:speed)

Parameters

Parameter Description
Physic:physicid Physics object that hit.
A3D_HIT:type What it hit.
hitid Model of the map object, or the physics object, static object, player, vehicle or actor it hit.
Float:x Point of contact on the X axis.
Float:y Point of contact on the Y axis.
Float:z Point of contact on the Z axis.
Float:speed Speed of the impact, in metres per second.

Remarks

The callback comes once when a contact starts, never while it lasts. It is called in the script that created the object, after the step that saw the impact, and its return value is not used.

  • speed is the speed at which both bodies met, along the line of the contact. Contacts slower than the collision speed of the object, 3dandreas.collision_speed by default, call nothing. See A3D_SetCollisionSpeed.
  • When two moving objects meet, each one gets its own call, in the script that created it, with the other as hitid.
  • Only moving objects get calls. The map, static objects, players, vehicles and actors are what they hit.
  • An object that falls asleep loses its contacts, so what it rests on counts as a new contact when it wakes. A collision speed above zero keeps those out.

It is safe to destroy the object inside the callback.

Example

Hurts a player by the speed of what hits them.

public A3D_OnCollided(Physic:physicid, A3D_HIT:type, hitid, Float:x, Float:y, Float:z, Float:speed) {
    if (type != A3D_HIT_PLAYER) {
        return 1;
    }

    new Float:health;

    GetPlayerHealth(hitid, health);
    SetPlayerHealth(hitid, health - speed * 2.0);

    return 1;
}

Related

  • A3D_SetCollisionSpeed: Set the slowest impact of a moving physics object that calls A3D_OnCollided.
  • A3D_OnStopped: A moving physics object came to rest, or fell below 3dandreas.floor and was stopped there.
  • A3D_SetExtra: Keep a number on a physics object, such as the item it stands for.

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