- Documentation
- Shared functions
- getDirectionFromRotation
Function
getDirectionFromRotation
Converts a heading (like the Z rotation in GTA) and pitch in degrees into a unit direction vector.
Syntax
vector3 getDirectionFromRotation(float heading [, float pitch = 0])Arguments
headingfloat- Heading in degrees.
pitchfloat, optional = 0- Pitch in degrees (positive is up).
Returns
The direction vector.
Example
A point 10 metres in front of the player.
local player = getRandomPlayer()
local x, y, z = getElementPosition(player)
local _, _, rz = getElementRotation(player)
local dir = getDirectionFromRotation(rz, 0)
local tx, ty, tz = x + dir.x * 10, y + dir.y * 10, z + dir.z * 10
createMarker(tx, ty, tz, "cylinder", 1.5, 255, 200, 0, 150)