Hi there. I have an Array<Node> and each item in this array has a script attached to it which contains a method with a tween function, to animate the node to a new position.
My problem is, that each Node in the array waits for the previous one’s tween to finish, before starting its own tween, ie they are working synchronously. But I want to the Nodes to call their tweens asynchronously.
The ways I have tried to implement this are (none of them working so far):
Async Function outside class:
async function letTween(node : Node, previousNode : Node, newPosition : Vec3) {
tween(node.position)
.to(0.5, newPosition,
{
onUpdate : async (target:Vec3, ratio:number)=>{
node.position = target;
},
easing : "bounceOut",
}).start()
}
AssetManager.Pipeline:
var pipeline = new Pipeline('sync', [(task, done) => {
let input = task.input;
tween(node.position)
.to(0.5, newPosition,
{
onUpdate : async (target:Vec3, ratio:number)=>{
node.position = target;
},
easing : "bounceOut",
}).start()
done();
}]);
pipeline.async(new Task());
I would appreciate any help.