Rotate the character
3D Characters
Assigning a Rotation
Same as transform.rotation, you can set the Rotation property directly using any Quaternion value you want.
Setting a direction property
Sometimes it is preferred to make a particular direction to point towards another one. In that case, you could modify any of the actor directions (properties):
By setting any of the direction properties there is no guarantee that the rotation applied will be the one you want. For instance, multiplying Forward by -1 does not mean a 180° Yaw rotation will be applied.
For more precise control over the rotation process, please use RotateYaw
, RotatePitch
and/or RotateRoll
.
Using the actor public methods
If you want get a more precise result, you can use RotateYaw
, RotatePitch
and/or RotateRoll
. These are all simple implementations based on Quaternion.AngleAxis
.
2D Characters
The 2D world is very different from the 3D world, especially regarding rotations. However, all of the principles and functions mentioned above apply here as well.
The big difference between 2D and 3D is that transform.forward
must be either Vector3.forward
or Vector3.back
. Otherwise, the collider size will get reduced.
The Forward
direction (actor property) is directly represented by transform.right
.
Last updated