Search code examples
unreal-engine4unreal-blueprint

What is a "Break Rotator" and "Make Rotator" in Unreal Engine 4?


So, I am beginner in Unreal Engine 4. I am having trouble understanding "Make Rotator" and "Break Rotator" on Movement Input of the character blueprint class. The original definition UE4 documentation has made me even more confused. Can anyone explain this in a simple way?


Solution

  • A FRotator (or just Rotator in BP) is Unreal's way of storing rotations.

    Usually, there are two main ways rotations are represented in programs:

    1. As three separate rotation values per-axis, which is called Euler rotation: one for how much you rotate on X, one for Y, one for Z. This is the "older" approach, and has its issues, mainly gimbal lock. Also, there's no standard, and different programs apply them in different orders (some programs do ZXY: Z first, X second, Y third, but other do XYZ etc).
    2. To solve the issues with Euler rotations, another option is used, with four separate values: three values denote the axis of rotation, and another one denotes the angle. This axis-and-angle value is called a quaternion (beacuse it has four values, quat is four in latin). Since any unique rotation mathematically can be expressed as an axis and angle, quaternion rotations are free of gimbal lock, and aren't dependent on any order.

    Unreal internally uses quaternions (FQuat), but they're a bit harder to explain and understand, than just three X Y Z rotations. Because of that, FQuat is only for C++, and on the Blueprint level the editor simply shows the rotation as three axis. That's what the Rotator is for.

    When you break a rotator, you just separate out the three float values for the XYZ rotations. When you make a rotator out of three float values, it makes the rotation that would result from them.

    These break and make nodes exist for many other types, like FVector (shown in BP as just Vector), FLinearColor (Linear Color), to easily make a more complicated thing, like a color or rotation, out of simple float values.

    Having said this, since the Rotator really represents an axis and angle, it's better not to use the make Rotator node, but the rotator from axis and angle node.

    Rotators are quite convenient, because there are many functions in Unreal to work with them, such as Lerp (Rotator) and others.