EntityClient

getEntitySpeedVector

GET_ENTITY_SPEED_VECTOR0x9A8D700A51CB7B0D

The GTA V native GET_ENTITY_SPEED_VECTOR of the ENTITY namespace, as LS:MP client scripts call it: the global function getEntitySpeedVector, in JavaScript and in Lua.

SignatureJavaScript
getEntitySpeedVector(
  entity: Entity,
  relative: boolean
): { x: number, y: number, z: number }
SignatureLua
getEntitySpeedVector(entity: Entity, relative: boolean): Vector3

Usage

JavaScript
const { x, y, z } = getEntitySpeedVector(entity, relative);
Lua
local coords = getEntitySpeedVector(entity, relative)
-- coords.x, coords.y, coords.z

Parameters

ParameterTypeJavaScriptLua
entityEntitynumberinteger
relativeBOOLbooleanboolean

Returns

Vector3 JavaScript { x: number, y: number, z: number }, Lua Vector3

A 3D vector. JavaScript gets a plain { x, y, z } object; Lua gets a real Vector3, with .x .y .z and arithmetic. As an argument, one vector fills three consecutive coordinates.

Notes

From the community native database. Names are LS:MP’s; samples may be written for C++ or another framework.

Relative can be used for getting speed relative to the frame of the vehicle, to determine for example, if you are going in reverse (-y speed) or not (+y speed).

Reference

Namespace
Entity ENTITY
In the game
Vector3 GET_ENTITY_SPEED_VECTOR(Entity entity, BOOL relative)
Hash
0x9A8D700A51CB7B0D

Open in the interactive natives reference