vehicles.getVelocity
Reads how fast a vehicle moves, in m/s, and how fast it spins about each world axis, in rad/s, as the server last saw it. Both are world-space vectors from the vehicle’s snapshot.
Signature
Section titled “Signature”vehicles.getVelocity(id: number): Vector3 | undefinedvehicles.getAngularVelocity(id: number): Vector3 | undefinedParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
id |
number |
The vehicle’s network ID. |
Returns
Section titled “Returns”A Vector3, or undefined for an unknown vehicle.
Example
Section titled “Example”import { server, vehicles } from "nativemp";
server.on("playerExitedVehicle", ({ player, vehicleId }) => { const velocity = vehicles.getVelocity(vehicleId); if (velocity && Math.hypot(...velocity) > 20) server.log(`${player.name} bailed out at speed`);});Related
Section titled “Related”vehicles.setVelocity: change itvehicles.getById: the whole snapshot