[SOLVED] Error with Tweenlite

Hi everyone

This is my project:

https://playcanvas.com/editor/scene/421469

The first level works fine, in the second, the player figurine suddenly doesn’t tween, and instead the enemy tweens, and the player gets “teleported” at the end. The player doesn’t fire the event after his tween, but calls the callback right away. Error must be on line 108 in player.js.
I know Tweenlite shouldn’t have callbacks in brackets, but if I remove them, nothing happens at all (onCompleteScope is set)…

It may be a bit much, but if someone could have a look into it, and help me, I would appreciate that gesture a LOT.

Best regards

Greg

I’ve never used TweenLite before so I don’t know how it works. I prefer Tween.js (which I used in my Flappy Bird clone - see here for details).

However, this line looks weird:

goal.onComplete= this.animateOver(this);  //<<<<<<--------goal.onComplete= this.animateOver(this);

Looks like you should be setting a callback function? But you are just calling a function that doesn’t return anything. Maybe you wanted to do this:

goal.onComplete= this.animateOver.bind(this);  //<<<<<<--------goal.onComplete= this.animateOver(this);

Notice the .bind.

Anyway, when you make this change, the character just jumps from point to point instead of tweening in the first level. This is because this.myTurn is always false. In the input function, it’s set to false, but never set to true again, which prevents this clause from being called:

if(this.myTurn===true){
    this.entity.setPosition(this.coordinates.x,this.coordinates.y,this.coordinates.z);
    this.entity.setEulerAngles(this.rotation.x,this.rotation.y,this.rotation.z);//...and Rotation to whatever may be in Tween.
}

Hope that helps a bit. :slight_smile:

Yup, that was it. That simple. Huge thank you from my part!!

This is actually (almost) correct, according to TweenLite I just had to remove the “(this)”, but when doing that, nothing worked anymore.

Thank you so much, again, Will!

1 Like

I’m reactaviting this thread with the hope you are still in there Greg.
Would you mind detailling how you implement Tweenlite in playcanvas?
I would use it ( and Tweenmax / Gsap) but I’m not sure of what to implement as a lib. Which .js have you added to your project and how do you call your tweenlite.
A very basic example project of a cube moving would help a lot :slight_smile:

Best

You should be able to just drag and drop the UMD file into the PlayCanvas project and the functionality would be available to use in the project :slight_smile: