multiply a variable with a delta timestep

In a small test project I recently started, I tried an differential approach to friction instead of a linear approach to friction.

For example, before I would do:


Vector normal = velocity.getNormal();
float magnitude = velocity.getMagnitude();
float change = magnitude - (friction * delta);
velocity = normal.multiply(change);

//

x += velocity.x * delta;
y += velocity.y * delta;

In my current project I am doing:


velocity = velocity.multiply(0.99);

//

x += velocity.x * delta;
y += velocity.y * delta;

This new method feels much nicer as friction, but it has one draw-back, I cannot use it with a delta timestep! How should I approach this?

If you have any kind of physics simulation, I strongly suggest to switch to fixed timestep instead of variable timestep with delta time. Just make with a decent gameloop, that you get a constant fixed update rate for your simulation. This will make it much easier and you also get deterministic reproducible behaviour.


- velocity = velocity.multiply(0.99);
+ velocity = velocity.multiply(1.00 - 0.01 * delta);

//

x += velocity.x * delta;
y += velocity.y * delta;

Having said that - use fixed timestep instead.