Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Start a free Basic trial
to watch this video
In the Inspector window, Unity displays rotation values using 360 degrees for X, Y, and Z, but that's just so that they're easier for us humans to understand. Behind the scenes, Unity stores rotations as a mathematical object called a quaternion. Unity provides methods for working with quaternions so that we can rotate 3D objects.
Unity Documentation

Quaternion  Quaternions are mathematical objects that represent a 3D rotation. In Unity, the
Quaternion
class has many useful methods and variables.

0:00
The frog character can move left and right but

0:03
it also needs to rotate and face the direction it's moving in.

0:08
Rotating an object immunity is slightly more complex than changing its position

0:15
but Unity includes special rotation methods to make it easier.

0:21
In Unity, the transform component only shows us the x, y, and

0:25
z values for position and for rotation.

0:29
We can manipulate the values for position directly in our code but

0:34
we cannot change the values for rotation in the same fashion.

0:39
Mathematically, rotating an object in

0:41
3D space is much more complicated than it may appear.

0:45
In the Inspector window, Unity displays rotation values using 360 degrees for

0:51
x, y, and z but that's just so that they're easy for us humans to understand.

0:57
Behind the scenes, Unity stores rotations as a mathematical object

1:02
called a Quaternion Unity and just about every other game engine uses quaternions

1:08
instead of x y z values because they solve a lot of issues with 3D rotations.

1:15
For example if were to directly manipulate the x y and

1:20
z rotation values of the frog character it might seem fine at first.

1:25
Over time however or in specific situations, bizarre problems can arise.

1:31
The frog might rotate in the direction that's different than what we expect or

1:36
it might get completely stuck and won't rotate at all.

1:41
The good news is that you don't have to understand the math of Quaternions to use

1:46
them in Unity because Unity has builtin methods for working with Quaternions.

1:52
In fact, most game developers,

1:53
myself included, don't fully understand the math of Quaternions.

1:58
But Quaternions are still used all the time.

2:01
It might seem strange to not fully understand the inner working

2:04
of the methods that we're using but it's best to think of them like an appliance.

2:09
I don't understand all of the inter workings of my refrigerator or my car but

2:14
I still use them all the time.

2:16
Similarly, Unity provides methods for working with quaternions so

2:21
that we can type in our code and

2:23
get a result, without possessing an advanced degree in mathematics.

2:27
Using Paternians will solve all the strange problems we might encounter if we

2:31
tried to directly manipulate rotation values.

2:37
Now that you have some idea of why we are using Paternians,

2:40
instead of normal x y z rotations, we're ready to learn about Paternian methods.

2:46
That will help us rotate the player character so

2:49
that it's facing the proper direction as it moves around.
You need to sign up for Treehouse in order to download course files.
Sign up