EntityClient

getEntityRotation

GET_ENTITY_ROTATION0xAFBD61CC738D9EB9

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

SignatureJavaScript
getEntityRotation(
  entity: Entity,
  rotationOrder: number
): { x: number, y: number, z: number }
SignatureLua
getEntityRotation(entity: Entity, rotationOrder: integer): Vector3

Usage

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

Parameters

ParameterTypeJavaScriptLua
entityEntitynumberinteger
rotationOrderintnumberinteger

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.

rotationOrder is the order yaw, pitch and roll is applied. Usually 2. Returns a vector where the Z coordinate is the yaw.

rotationOrder refers to the order yaw pitch roll is applied; value ranges from 0 to 5 and is usually *2* in scripts.
What you use for rotationOrder when getting must be the same as rotationOrder when setting the rotation.

What it returns is the yaw on the z part of the vector, which makes sense considering R* considers z as vertical. Here's a picture for those of you who don't understand pitch, yaw, and roll: https://web.archive.org/web/20160825124935/www.allstar.fiu.edu/aero/images/pic5-1.gif

Rotation Orders:
0: ZYX - Rotate around the z-axis, then the y-axis and finally the x-axis.
1: YZX - Rotate around the y-axis, then the z-axis and finally the x-axis.
2: ZXY - Rotate around the z-axis, then the x-axis and finally the y-axis.
3: XZY - Rotate around the x-axis, then the z-axis and finally the y-axis.
4: YXZ - Rotate around the y-axis, then the x-axis and finally the z-axis.
5: XYZ - Rotate around the x-axis, then the y-axis and finally the z-axis.

Reference

Namespace
Entity ENTITY
In the game
Vector3 GET_ENTITY_ROTATION(Entity entity, int rotationOrder)
Hash
0xAFBD61CC738D9EB9

Open in the interactive natives reference