I bought the Synty Farm Asset pack recently. The demo level looks great, except for the fact that the windmills dotted around the farm are not rotating. This looks a little bit out of place with the rest of the animated scene. Being the newbie that I am, I was wondering how I could make the mills turn, and thankfully I’ve found a solution. Over the years I’ve found another way to make this happen, so I’ll share both options with you.
Option 1: Using Local Rotation
For our first option, we need is an AddActorLocalRotation node. Type “rotation” in the search field and you’ll see a huge variety of nodes popping up. Some others will work, however in my experiments, the ones suggested by other sources did not rotate my object 360 degrees (let alone indefinitely). AddActorLocalRotation seems to do the trick though.
Next, drag off the Delta Rotation parameter and add a Make Rotator node. This will let us choose around which axis the object needs to be rotated. Thankfully we’re getting XYZ values in addition to the more “proper” values which sadly mean nothing to me. From the object in my viewport I can tell that I need the Y (Pitch) value for the fan, but a rotating coin or ammo pickup item would need the Z (Yaw). The simplest way to make this thing spin is to hack in a value here manually.
A more elegant way would be to promote our desired input to a float variable. The advantage is that we can now set the value from outside the Event Graph, and without having to re-compile the Blueprint if we want to make a change to the rotational speed. Most importantly, we must multiply our spin rate with the Delta Seconds as this will assure a cohesive rotation rate regardless of frame rate (thanks to Dejan for pointing this out).
Click Simulate to see the effect in the viewport, or play the level with your Blueprint actor in the scene.
Option 2: Rotating Movement Component
Unreal Engine has a built-in component we can use called the Rotating Movement Component. Like a static mesh, it can be added to our Blueprint Class (much like a Character Movement component). It will add indefinite rotational movement without any code. As an example, for a rotating coin we can do something like this:
Once added and selected, the details panel offers values we can use to make out object spin. Play with the values and see how they behave.