Randomize clockwise and counterclockwise rotation

I want this gear or a gauge needle to spin in random amounts clockwise, counterclockwise, counterclockwise, clockwise… etc always against itself, rather slowly and smoothly

This is from the Steampunk Props pack (BP_Gear). I have tried putting Random Floats in Range (and CombineRotators) between SpinTimeline and Make Rotator, but it’s just spinning around too quickly. It has to be slow.
Any input would be awesome.

You could use the rotating movement component depending on the situation. How you actually implement it will be dependent on the needed function and situation. Below is an example. For this example i was thinking of a gear working as set dressing, decoration, or maybe a puzzle.

to begin we create a new actor, add a mesh component (gear), and add the rotating movement component. if you look in the below picture in the details panel you will see rotation rate which is how you control the rotation speed and the axis of rotation. for the script we begin by creating a custom event (ChangeRotationDirection) which will be called when we want the rotation to be changed. the next two parts are to add in some randomness. first since the rotation will be at a constant rate we will use time to determine how “far” the gear has rotated, this is basically just how often we will change the direction which i set to a random time between 1-3 seconds. this time is then fed into a delay. next i added in a bit of randomness by having a chance that the change of rotation wont occur. for this i used a branch and a weighted bool. the weighted bool gives us something like a percentage that it will be true, i set this to 0.8 or 80% the bool will be true. if the branch is true then we simply get the rotating movement component, then get the rotation rate, multiply it by -1, and finally set the rotation rate. what this does is it says ok your rotating x degrees per second, now i want you to change to -X degrees. you could also use this to vary the speed. the last thing we need to do is to loop the script so it runs again, so we call the custom event (this is also done if the branch is false).

Godsend answer… thank you. This is one of the most important parts of the game.

I’m sure you know how to cap a a needle oscillating only within the upper 180° degress. (See the green/red meter in this picture)

284001-download-3.jpg

Cheers

using this method i cant think of a good way to limit the rotation without just doing constant checks.

Still an amazing contribution. Please let me know if it ever comes to you - even with a different method. X-axis In a 180° Range (or something like that).

Look what I have found. Does it makes sense to attach it there?

Edit: So far it just stops mid-spin when setting it to -180 or 180.

I’m currently experimenting with a custom function called ClampAngle that begins At Play, sequenced after Change Direction. I hope that you can see something that I don’t.