Rotation in UE4 has such complete implementation that it can be hard to choose how to rotate your objects. There are three main methods—FRotator
, FQuat
, and FRotationMatrix
. This recipe outlines the construction and use of the first of the three different methods for the rotation of objects—the FRotator
. Using this, and the following two recipes, you can select at a glance a method to use to rotate your objects.
Have a UE4 project that has an object you can get a C++ interface with. For example, you can construct a C++ class Coin that derives from Actor
to test out rotations with. Override the Coin::Tick()
method to apply your rotations from the C++ code. Alternatively, you can call these rotation functions in the Tick
event from Blueprints.
In this example, we will rotate an object at a rate of one degree per second. The actual rotation will be the accumulated time since the object was created. To get this value, we'll just call GetWorld...