getElementVelocity
Shared
Returns an element's velocity.
vec3|false getElementVelocity(element element)
Parameters
| Name | Type | Description |
|---|---|---|
| element | element | The element: a ped, player, vehicle or object. |
Returns
A vec3 with the velocity in units per simulation step, or false if the element has no velocity.
Example
local vehicle = getPedOccupiedVehicle(localPlayer)
if vehicle then
local velocity = getElementVelocity(vehicle)
local speed = math.sqrt(velocity.x ^ 2 + velocity.y ^ 2 + velocity.z ^ 2)
outputDebugString(("speed: %.3f"):format(speed))
end