Head Bobbing Moves much faster With different Screen Resolutions?

I have attempted to implement a head bobbing feature into my FPS game like the old games used to have. But i noticed when i change the resolution the headbobbing is much faster. Here is my bobbing code:

public void cosSim() {
if (cosSim_Inc) {
if (cosSim_Pos) {
cosSim += cosSim_Speed;
if (cosSim > cosSim_Max) {
cosSim_Pos = false;
//cosSim = cosSim_Max;
}
} else {
cosSim -= cosSim_Speed;
if (cosSim < -cosSim_Max) {
cosSim_Inc = false;
cosSim_Dec = true;
cosSim_Pos = true;
cosSim = -cosSim_Max;
}
}
} else if (cosSim_Dec) {
if (cosSim_Pos) {
cosSim -= cosSim_Speed;
if (cosSim < -cosSim_Max * 1.5f) {
cosSim_Pos = false;
//cosSim = -cosSim_Max * 1.5f;
// FOOTSTEPS
//if (MOVING) {
// playSound(pickRandom(footStepSounds), “footsteps”, “”);
//}
}
} else {
cosSim += cosSim_Speed;
if (cosSim > cosSim_Max * 1.5f) {
cosSim_Pos = true;
cosSim_Inc = true;
cosSim_Dec = false;
cosSim = cosSim_Max * 1.5f;

            }
        }
    }
}

i call this function and then do this to the camera:

cosSim();
cam.setLocation(cam.getLocation().addLocal(new Vector3f(0.0f, cosSim, 0.0f)));

This results in the camera bobbing up and down. But it moves up and down much faster when i run the game at smaller resolutions? What could be the issue? Thanks a lot :slight_smile:

use add instead of addLocal and see if that helps

i cant help but notice you dont use tpf anywhere in that code…

3 Likes