Hey all,
I am having an issue where different frame-rates are giving me slightly different movement speeds. Can anyone see an issue with my movement script? This is within the update function. I’m including delta time in my calculations so I’m just a bit confused. Let me know if anyone sees anything. Before the translation there is an acceleration multiplier to smooth the movement out a bit. Walking from point a to point b at 60 fps vs. 30 fps there seems to be about a 20-30 perfect speed difference (30 fps has faster movement than 60). Here is the script:
if(this.isLeftButtonPressed || this.isRightButtonPressed || this.isUpButtonPressed || this.isDownButtonPressed){
//scale movement coefficient so that the movement has a bit of acceleration
if(this.movementCoefficient <= 1){
this.movementCoefficient += dt*12;
}
}
else{
this.movementCoefficient = dt;
}
//if not swinging, move
if(!this.isSwinging){
if(this.isLeftButtonPressed){
this.entity.translate(dt*-this.movementSpeed*this.movementCoefficient,0,0);
}
if(this.isRightButtonPressed){
this.entity.translate(dt*this.movementSpeed*this.movementCoefficient,0,0);
}
if(this.isUpButtonPressed){
this.entity.translate(0,dt*this.movementSpeed*this.movementCoefficient,0);
}
if(this.isDownButtonPressed){
this.entity.translate(0,dt*-this.movementSpeed*this.movementCoefficient,0);
}
}