How to make a timed click bar

How would you create one of those things with the pendulums that go back and forth that you have to put an input in at the time its pendulum bottom is over green? Maybe like this:

Just looked for an image and this is what showed up.

When the pendulum swings, you can use tweening perhaps to move it back and fourth to specified target values. (e.g: a min rotation of -45, and a max of 45)

When the user clicks, stop the ongoing tween and then determine where the pendulum’s rotation ended up.

To figure out which part of the zone the pendulum landed on, you can use a simple range check. (e.g: for it to be in the green zone, the rotation would have to be -20 to 20 degrees, just as a random example)

You could add additional range checks to determine if it’s in either of the other yellow or red zones.

Only thing that might require a bit of patience is rotating the pendulum from an origin point (and not the center of the image, which you can’t really change without code.) I’d recommend implementing an algorithm off of Google or something for this, it shouldn’t be too hard.


Does anyone know how to make the bar shown? (Like, with randomly generated green areas?)

You mean random generated ranges so it random chooses where the green position is? For example the first one is in the middle and the next one is to the left?



You could probably use UIGradients to fill your meter with different colors at different positions.