Nevermind, i forget to remove the old function.
Is there a way to fire the function from the player script?
(The function itself is on the enemy script).
Nevermind, i forget to remove the old function.
Is there a way to fire the function from the player script?
(The function itself is on the enemy script).
Yes use events, check how I did it in the sample above.
The function is fired from the movement.js script.
Ah i thought it has to be on the same object but it donât has to.
It works fine now. Thanks a lot!
I use a boolean to use a tween in the update. So maybe i can help others to with this example:
this.isStarted = false;
Tween.prototype.update = function(dt) {
if (this.isStarted === false) {
this.isStarted = true;
entity.tween(entity.getLocalPosition())
.to({x: 10, y: 0, z: 0}, 1, pc.Linear)
.on('complete', function () {
console.log('tween completed');
this.isStarted = false;
});
}
};
Thatâs great! Thanks for sharing, indeed if you make sure that the tween doesnât start/stop per frame then there is no reason to not have it in your update loop.
By the way this line:
var this.isStarted = false;
Should be like this, a property assignment doesnât require creating a new var:
this.isStarted = false;