Clone entity and run animation again and again

I only respond to topics or posts if I can say something meaningful about it. My knowledge is limited.

So what I am doing here is

data?.result[0]?.runners[0].card[0]

from here I get the same data for X amount of time, and it is repetetive, so I have set the states, so basically when I first get a response I set a state as true, hence animation runs, and in the if I set state as false , thus even though I get the same value it will not go inside the if loop, and as soon as I get a empty value of card it sets the sate as true again and once new card comes in , it will begin the whole animation for next card

Alright, I think I kind of get it. Wouldn’t the on complete function of the tween be a better alternative? I use it in my example project. You can also create a timer.

I have set my animations in different scripts for a reason , thats because I want to trigger those different keyframes at any point of time
now since I am using oncomplete function , will it trigger my next script as sooon as the animation in this script is done?
Like I want to understand how it onComplete() a better option than my current code and how will it work for a queue of animations in different scripts

You talk about animations, but I only see one or two tweens that rotate and change the position of the card, like I do in my example project. So do you mean the tweens or do you mean animations that I didn’t see yet?

lets go with tweens, I am moving my object from one place to another

That’s right, please look at the manager script in my example project. There I use it to execute the addCard function when the tween is ready.

As an alternative you could use a timer.

// initialize function
this.timer = 0;
// update function
this.timer += dt;

// execute your function every 10 seconds
if (this.timer > 10) {
    this.timer = 0;
    // your function
}

Offcourse you can add more conditions to the statement, to prevent your function is executed when you don’t want it.

If your function is in another script, you could use events or reach the function like below.

otherEntity.script.scriptName.yourFunction();

Okay thank you