After recently realizing that this forum's demographic includes a lot of programmers, I thought I would post a question I have...
I am trying to figure out how to simulate friction in a frame-rate independent way, and also in a way that it can be predicted so I can do dead-reckoning / convergence using the predicted position.
Right now, I just do...
Velocity *= FRICTION_FORCE;
...except that's not frame rate independent.
My current solution is to use a specific frame rate for my physics (so it is guaranteed to run once for every 0.1 seconds), and then for the prediction I do...
float N = (1 / Player.PHYSICS_RATE);
float APY = (float)Math.Pow(1.0f + Player.FRICTION / N, N) - 1.0f;
LookAheadPoint = packet.Position + APY * (packet.Velocity + packet.Acceleration * LOOK_AHEAD_TIME) * LOOK_AHEAD_TIME;
...using the Annual Percentage Yield formula to try to predict it...
So does anyone know a better way to simulate friction in a frame rate independent way? This way feels like a hack. :P
Post edited by Unknown User on
[ Rek | Reklys | remedy | blu.knight | Psyke | Sky ]
I have way too many names.