1
Vote

Chase Camera Slow Framerate Odd Behavior

description

If the framerate falls for some reason (as when a taskbar notification pops up) the chase camera seems to run away from the object it is chasing. This seems to be caused by numerical error in the calculation of the chase velocity and acceleration.
 
To fix this, I added a simple check in the logic just before the acceleration and velocity are calculated, clamping the elapsed to 1/10 of a second, like this:
 
        if (elapsed > 0.1)
        {   
            // Clamp elapsed
            elapsed = 0.1f;
        }
 
 
This seems to have worked nicely - I know it hasn't "fixed" the numerical error, but it did what I needed it to do.

comments