Spark AR random rotation patch path

Hi all,

I want to create a random rotation filter with Spark AR.
There’s a circle/wheel on the facetracker and each time you spin the circle/wheel it needs to land on another frame. The wheel exists of 7 parts.

Does anyone know the patch paths that goes well for this?

Many thanks!

There’s a handy “stepping” technique where you take a value from 0-1 and multiply, round, then divide to create a stepped output.

You might also need to offset it by 0.5/7 * 360 if you have issues with centering the items in the wheel.

If you need to have a spinning motion for a few revolutions, I think you could just add 720 to the stepped value.

It gets a little tricky if you want it to be seamless transitions. You could use some delay values to track the previous ending position and feed it back in to the starting position. I wrote an article on delay value in case you are unfamiliar with it.

Hi Josh,

Thank you so much for this - really appreciated!

I had look around with Spark AR and came to another solution for spinning the wheel.
I created now 1 PNG sequence for the wheel. When the randomiser stops on an option I want to show an image on screen. Do you know how I can ‘trigger’ the visibility of the image after the randomiser stops on number 2 for example?

Here’s the path I’ve created so far:

Many thanks!

You can plug the random value into an option picker to select a texture, then send that to a material.

Another option would be to set the visible state on individual images, based on if the random value equals a specific number.

Thank you for your fast response!

If I do this the image (belong to number 2) shows up while it’s looping, but it needs to be visible after looping. Sorry, I’m quite new to this :frowning: I think I miss a step in the path right?

You don’t need the option picker to select a number, since you are already getting a number from the random patch. You are correct in that you need to round the value, but more specifically, I think it needs to be floored. That will give you an integer value that you can use “equals exactly” to enable the answer image

Perfect, thank you! The only thing that still happens is that all the images run while the sequence is looping, but it needs to be shown after the sequence loop. Do you think that’s possible?

There is something in the library for this: “Store Value is a patch asset created using a Delay Value patch. This patch asset stores an input value the instant a pulse is fired.”

All you need to do is send the pulse to that patch when it stops spinning (looks like that one just after the delay)