Animation with javascript

I have a problem with the script, I made 3 planes and I animated it with the script, but when I tried to stop the animation, only 1 plane stopped. does anyone have a solution?

Thank you.

const Random = require(‘Random’);

const Animation = require(‘Animation’);

const Reactive = require(‘Reactive’);

const Time = require(‘Time’);

const Diagnostics = require(‘Diagnostics’);

export class Pipe1{


this.defaultY0 = defaultY0;

this.timeDriver ;

this.availabe = true;

this.timeDriverParameters = {

  durationMilliseconds: 3000,

  loopCount: Infinity,

  mirror: false





this.timeDriver = Animation.timeDriver(this.timeDriverParameters);

const linear = Animation.samplers.linear(.3, -.3);

const translationAnimation = Animation.animate(this.timeDriver, linear);

plane0.transform.x = translationAnimation;

plane1.transform.x = translationAnimation;

plane2.transform.x = translationAnimation.add(0.02);

let Randomy = Reactive.toRange(Random.random(),-0.15,-0.3)

plane0.transform.y = Randomy.add(0.4);

plane1.transform.y = Randomy;

plane2.transform.y = Randomy.add(0.2);


let RandomY = Random.random()

plane0.transform.y = Reactive.toRange(RandomY ,-0.15,-0.3);

plane1.transform.y = Reactive.toRange(RandomY ,-0.15,-0.3).add(0.4);

plane2.transform.y = Reactive.toRange(RandomY ,-0.15,-0.3).add(0.2);

plane2.hidden = false;







I tested your script. All three planes stopped.
Do you want to stop the first plane only?

1 Like

I want every planes to stop.

this is my results.

when i tap

spawn function

when collided

over function

is there something wrong in my script?

When you call spawn() of pipe11 for the second time after the delay, the this.timeDriver of pipe11 is redefined to another Animation.timeDriver so the original timeDriver lose control.

what should i do to stop all planes?
i tried to make another class with the same method, but the planes would stop one by one.
in this case I just try to make a delay when the game starts but when the game is over there is no more delay.

You need to store all of your animations in somewhere.
I have a wrapper for animation, it can return the animation driver.

Here is the example for your use case:
example.arprojpkg (7.7 KB)


Thank you so much! :pray: