Delay between Play animations (TypeScript)

Hi all, I’m trying to learn TypeScript but I have really great difficulty to make simple commands…
For example:
const girl = Scene.getItem(‘Item ID’) as AnimatedItem
girl.animation.playLooping(“Walk”)
delay(5) //play looped 5 seconds walk animation
girl.animation.playLooping(“Cheer”)
delay(2). //play looped 2 seconds cheer animation
girl.animation.playLooping(“Neutral”)
How can implement a delay?
Thank you, Giuseppe

Hi Giuseppe, I think Geoff is the one who can help you @techleapnz

1 Like

Hi @Giuseppe_Schiuma,

Unfortunately, the answer is not pretty. We need to use the Time.schedule function inside itself to mimic the delay.

girl.animation.playLooping("Walk");

Time.schedule(
    function(){
        girl.animation.playLooping("Cheer");
        Time.schedule(
           function(){
                girl.animation.playLooping("Neutral");
            },
            2
        );
    },
    5,
);

Hope that helps! Let me know if you have any further questions about this. If this solves your problem, please mark this post as the Solution.

Many thanks,
Geoff @ TechLeap

2 Likes

Hi @techleapnz, it works! Thank you.

giuseppe.animation.playLooping(“Cheers”)

2 Likes