What is the best way to do timed events

Hi All,
Thanks for reading.

What is the best way in PlayCanvas to trigger sets of animations based on timings?

For example after 10 seconds run animation scene 1
After 20 seconds stop animation scene 1 and start running 2
After 40 seconds stop animation scene 2 and start running 3

each scene would animate multiple entities

I was thinking of a script attached to the camera which sets a global variable which holds which scene is running
and changes the scene at timed intervals. And then in the update on the entities the animation would run depending on the contents of this variable.

also in ThreeJS there is a great tool called TweenJs which is great for tweening animations, has anyone used this with playcanvas?

Hi there,

Having the same background (create.js), I also wondered about this. @dave recommended Greensock’s TweenLite and/or TweenMax, and they really do a great job for me :slight_smile:.

Check out the Flappy Bird project for a use of tween.js:

https://playcanvas.com/project/375389/overview/flappy-bird

Tween.js is here:

https://playcanvas.com/editor/code/375389/tweenlib.js

It was taken from here:

It’s added to the Script Priority dialog to ensure it’s loaded first. I then wrote a tween.js script to apply to entities:

https://playcanvas.com/editor/code/375389/tween.js

This creates the following UI on an entity’s script component:

I use it to tween the scoreboard onto the screen when it’s Game Over. Works pretty well. :smile:

To fire that particular tween, I just do the following in script:

app.fire('ui:showscoreboard');

Ok , well thats just awesome !. Is there anything playcavas cannot do :wink:

1 Like