Unity provides a few operators that can make some common tasks with quaternions easier to accomplish. You can multiple a quaternion and vector to rotate the vector by the provided quaternion’s rotation or multiple two quaternions together in order to add the two rotations they represent together. These features make it easier to orient vectors in 3D space and can improve how you handle rotations (one common pattern I’ve seen that this can replace is the use Quaternion.Euler
with a series of stored X, Y and Z rotations).
Examples
If we wanted to rotate a forward facing vector by 45 degrees along the Y axis we might write something that looks like this:


Note: multiplying a quaternion and vector requires that the quaternion be on the left hand side of the operation and the vector be on the right hand side. You will see an error otherwise. Use
Quaternion * Vector
not.Vector * Quaternion
To perform a 90 degree rotation around the X, Y and Z axis you might do this:


Unity has provided additional examples and documentation for Quaternion
multiplication operations here: https://docs.unity3d.com/ScriptReference/Quaternionoperator_multiply.html
Join the World of Zero Discord Community: https://discord.gg/hU5Kq2u