Tweening for certain time interval

Hi ,
I am working in some multiplayer game .In some scenerio i was not able to tween the entity
so, my requirement is to for certain time: example for 15sec the ball should be hit to some height in multiple times in certain time interval consider as 15sec


anyone could suggest me to work it
thanks!

Hi @Michael_jef and welcome! Do you mean you want to create a timer to prevent the tween is running repeatedly?

Hi @Albertos so, present tween is happening single time , so i wanted to run the tween continously in certain time period Say as 15 sec , so withiin 15sec the tween should be continously run after 15sec it should stop

Hi @Michael_jef ,

It sound like you want the tween to repeat for 15 seconds then stop? You can do that with the repeat function by doing the math for how long it takes to complete one tween and then divide 15 seconds by it. Two ways you might do this, depending on whether you want the tween to pingpong might be:

//No Pingpong
this.cube.tween(this.cube.getLocalPosition())
.to({x: 0, y: 2, z: 0}, 0.5, pc.ElasticOut)
.repeat(30)
.start();

//Pingpong
this.cube.tween(this.cube.getLocalPosition())
.to({x: 0, y: 2, z: 0}, 0.5, pc.ElasticOut)
.repeat(30)
.pingpong(true)
.start();

I hope this is helpful.

2 Likes

Thankyou @eproasim