Unity has a Euler method on their Quaternion class. According to the docs it takes a Vector3 as an argument and returns a rotation in the form of a Quaternion. Since Unity’s Rigidbody.rotation is also a Quaternion you can do something simple like:
GetComponent<Rigidbody>().rotation = Quaternion.Euler(0, 0, -5);
What would be the equivalent operation on a PlayCanvas entity that has a rigid body component?
The rigidbody has a teleport function that allows you to set the position and rotation (euler or quaternion) of the rigidbody.
The Quat class also has a setFromEulerAngles:
So I could do something like that?:
var newRotation = new pc.Quat().setFromEulerAngles(0, 0, -5); this.entity.rigidbody.teleport(newPosition, newRotation);
Yep, or:
this.entity.rigidbody.teleport(newPosition, new pc.Vec3(0, 0, -5));