Rotation API in Core

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

Constructor

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)

Constants

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.ZERO
Code language: JavaScript (javascript)

Properties

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) --90
Code language: JavaScript (javascript)

Operators

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 * globalForwardVector
Code language: PHP (php)
Scroll to Top