Hello! I can’t figure out why my tweening seems to increase duration bit by bit even though I am using linear easing. I want to have my entity move to one side and flip 180 degrees in three seconds.
This is my code for rotation.
Rotation.prototype.update = function(dt) {
this.timer += dt;
if(this.timer > 3){
this.entity.translateLocal(0,0,0);
this.entity.rotateLocal(0,180,0);
this.timer = 0;
}
};
The tweening only uses the basic code provided by PlayCanvas with these settings changed.
TweenPosition.attributes.add('duration', {type: 'number', default: 3});
TweenPosition.attributes.add('easing', {type: 'string', default: 'Linear'});
TweenPosition.attributes.add('delay', {type: 'number', default: 0});
TweenPosition.attributes.add('loop', {type: 'boolean', default: true});
TweenPosition.attributes.add('yoyo', {type: 'boolean', default: true});
This is how I changed the position
this.tween = this.entity.tween(this.entity.getLocalPosition())
.to(new pc.Vec3(this.entity.getLocalPosition().x + 4, this.entity.getLocalPosition().y, 0), this.duration, pc[this.easing])
.delay(this.delay)
.loop(this.loop)
.yoyo(this.yoyo);
For the first few seconds, the rotations align with the tween but after a few more seconds, the tween’s duration seems longer, so the rotation happens earlier than the object moving back to its original position.