I’m developing my Voxel Based game and i’m facing a strange issue: When I move my player with BetterCharacterControl it walks more then what is specified when i’m loading some chunks, even using tpf, as you can see on video below:
The code where I move the character is this:
@Override
protected void controlUpdate(float tpf) {
camDir.set(0, 0, 1); //For debug i'm just walking along Z axis.
walkDir.set(0, 0, 0);
if (backFront > 0) {
walkDir.addLocal(camDir.negate());
} else if (backFront < 0) {
walkDir.addLocal(camDir);
}
walkDir.multLocal(200f * tpf);
playerControl.setWalkDirection(walkDir);
if (jump && playerControl.isOnGround()) {
playerControl.jump();
}
backFront = 0;
jump = false;
}
I know this is caused by the low frame rate instant, but as far as I know, the walkDir.multLocal(200f * tpf); should do the trick. What i’m missing?
Mann!!! It worked like a charm! Aparently, BetterCharacterControl uses tpf internally. I’ll confirm to be sure. My desired walking speed is 2 meters, so removing the tpf and setting move speed to 2f solved it
walkDir.multLocal(2f);
Now I ask to myself: Where I got this 200* tpf?
Anyway, for future reference of visitors:
@Override
protected void controlUpdate(float tpf) {
camDir.set(0, 0, 1); //For debug i'm just walking along Z axis.
walkDir.set(0, 0, 0);
if (backFront > 0) {
walkDir.addLocal(camDir.negate());
} else if (backFront < 0) {
walkDir.addLocal(camDir);
}
walkDir.multLocal(2f);
playerControl.setWalkDirection(walkDir);
if (jump && playerControl.isOnGround()) {
playerControl.jump();
}
backFront = 0;
jump = false;
}