Rotator
Rotators are very similar to Vectors.
They are used to represent a rotation of an object in 3D space.
CAUTION
Players should never have Pitch and Roll (other than 0) applied to them!
Only Yaw is relevant for players to represent a direction they are facing.
Members
Rotator consists of three scalar float values: pitch, yaw, roll
All of these can be simply retrieved like values in a Lua table.
local rot = Rotator(1,2,3)
print(rot.pitch)
print(rot.yaw)
print(rot.roll)Rotator constructor
Rotator can be constructed directly using a function of the same name, or it can be retrieved as a result of various functions.
Syntax:
Rotator Rotator( [ float pitch, float yaw, float roll ] )Example:
local rot0 = Rotator()
local rot1 = Rotator(5)
local rot2 = Rotator(5,10)
local rot3 = Rotator(5,10,4)getForwardVector function
Returns a unit Vector pointing in the direction this rotation is facing.
Syntax:
Vector Rotator:getForwardVector()Example:
local rot = player:GetRotation()
local dest = player:GetPosition() + rot:getForwardVector() * 300TIP
For simple cases, Vector:getInFront does the same in a single call.
getRightVector function
Returns a unit Vector pointing to the right of this rotation.
Syntax:
Vector Rotator:getRightVector()getUpVector function
Returns a unit Vector pointing up relative to this rotation.
Syntax:
Vector Rotator:getUpVector()