Hey guys,
PROJECT LINK - https://playcanvas.com/editor/scene/882405
I am trying to tween an entity left and right based on left and right key presses. I have two functions as described below.
TweenRotation.prototype.reset = function () {
// if we are already tweening then stop first
if (this.tween) {
this.tween.stop();
}
// create a new tween using our script attributes
this.tween = this.entity.tween(this.entity.getLocalRotation())
.rotate(new pc.Vec3(0, 0, 180), this.duration, pc[this.easing]);
this.tween.start();
};
reset();
, which tweens the entity to the left.
TweenRotation.prototype.reset2 = function () {
// if we are already tweening then stop first
if (this.tween) {
this.tween.stop();
}
// create a new tween using our script attributes
this.tween = this.entity.tween(this.entity.getLocalRotation())
.rotate(new pc.Vec3(0, 0, -180), this.duration, pc[this.easing]);
this.tween.start();
};
And reset2();
, which tweens to the right. The first time I press the right key, it tweens properly. However, after that, second and beyond, it tweens left regardless of the opposite direction specified. Could someone please help me out with this?