Rotation API in Core

The Rotation API page has useful information on how to create a Rotation and how it can be used.


Creating a Rotation is similar to creating a vector. It requires using a constructor function.

--Create a Rotation with the values (0, 0, 0)
local rot1 = Rotation.New()

-Create a Rotation with the values (90, 0, 180)
local rot2 = Rotation.New(90, 0, 180)

--Create a Rotation that is flipped upside down
local rot3 = Rotation.New(Vector3.FORWARD, -Vector3.UP)Code language: PHP (php)


Rotations only have one type of constant for a value of all zeros.

--Create a Rotation with the values (0, 0, 0)
local rot1 = Rotation.ZEROCode language: JavaScript (javascript)


Rotations have a property for each Euler angle component.

--Create a Rotation with the values (0, 0, 0)
local rot1 = Rotation.ZERO

--Change the Y property of rot1
rot1.y = 90

print(rot1.y) --90Code language: JavaScript (javascript)


There are a couple of math operations that can be done with Rotations, but the most important one is the Rotation * Vector3 because it can get the relative local coordinate vectors based on a certain Rotation.

--Get an object's world Rotation
local objectRotation = object:GetWorldRotation()

--Get the global forward vector
local globalForwardVector = Vector3.FORWARD

--Calculate the object's forward vector
local objectForwardVector = objectRotation * globalForwardVectorCode language: PHP (php)
Scroll to Top