How to drive the animation sequence "current frame"?

In Spark AR, we can drive the animation sequence manually using object tap, counter, and current frame like this:

How to do it in Lens Studio?

The answer is here Obj Touch Controller - #6 by Jorik_Rosa
Also, tap to change the script

// -----JS CODE-----
// @input SceneObject[] obj
var count = 0;
script.obj[0].enabled = true;
for (var i = 1; i < script.obj.length; i++)
{
script.obj[i].enabled = false;
}
function onTapped(eventData)
{
count++


for (var i = 0; i < script.obj.length; i++)
{
if (count == i)
{
script.obj[i].enabled = true;
}
else
{
script.obj[i].enabled = false;
}
}


if (count == script.obj.length)
{
count = 0;
script.obj[0].enabled = true;
}
}
var event = script.createEvent("TapEvent");
event.bind(onTapped);
1 Like

Wow. thanks for the super fast response man!

do you mind sharing the screenshot of how to set up the script and assign it to a counter that change each frame of the animation sequence in LS?

Are those codes for the script graph or just script?
*once again, sorry as I said before I’m still super new to LS, so… yeah :sweat_smile:

1 Like

ohhh if you want to change frames of animation sequence you needed to adjust the code :slight_smile:

Here’s a guide with a bit of script at the end: 2D Animation - Lens Studio by Snap Inc.

And the API docs for the AnimatedTextureProvider

But… there’s no way to set the current frame from what I can tell. Instead of using a texture sequence, you could just make an array of image assets and set the material’s texture from there.