GetEntityRotation
Docslocal retval = GetEntityRotation(entity, rotationOrder)Description
NOTE: What you use for rotationOrder when getting must be the same as rotationOrder when setting the rotation.
enum eRotationOrder {
// Rotate around the z-axis, then the y-axis and finally the x-axis.
ROT_ZYX = 0,
// Rotate around the y-axis, then the z-axis and finally the x-axis.
ROT_YZX = 1,
// Rotate around the z-axis, then the x-axis and finally the y-axis.
ROT_ZXY = 2,
// Rotate around the x-axis, then the z-axis and finally the y-axis.
ROT_XZY = 3,
// Rotate around the y-axis, then the x-axis and finally the z-axis.
ROT_YXZ = 4,
// Rotate around the x-axis, then the y-axis and finally the z-axis.
ROT_XYZ = 5,
}Parameters
| Name | Type | Description |
|---|---|---|
entity | Entity | The entity to get the rotation for. |
rotationOrder | int | The order yaw, pitch and roll is applied. Usually 2. |
Quick Snippet: Get Entityentity
entityUse this to obtain an entity handle from the player's aim or crosshair.
-- Get the entity the player is aiming at
local ped = PlayerPedId()
local hit, entity = GetEntityPlayerIsFreeAimingAt(PlayerId())
if hit and entity ~= 0 then
print("Entity: " .. entity)
print("Model: " .. GetEntityModel(entity))
print("Type: " .. GetEntityType(entity)) -- 1=Ped, 2=Vehicle, 3=Object
endReturns
Vector3Returns a 3D vector (x, y, z).
Examples
Official
local playerRotation = GetEntityRotation(PlayerPedId(), 2)
print(playerRotation)