问题
Here's the first version, where I have a delta of 1/60: http://jsfiddle.net/ocdrd0uy/
Here's the second version, where the only thing I changed was the delta to 1/20: http://jsfiddle.net/ocdrd0uy/1/
var delta = 1 / 60; --> var delta = 1 / 20;
I simply timestep like this:
x = x + v * dt * 0.5
v = v + (F * 1/m) * dt
x = x + v * dt * 0.5
Why does the player move faster with higher delta?
回答1:
It's quite logical that when your delta decrease, the speed will increase.
After you do your 2 half-step integration, you clear the force.
So, since you don't set it again elsewhere, what you are doing is applying the force (to change the velocity) during delta
on the first tick, then no more force is applied.
So the speed after first tick changes depending on the delta, then speed remains at that level.
To correct that, i'll have to know what you're trying to model.
If you're trying to model an initial 'punch' that is due to a force applied during a very short time, just apply F
during punchDuration
to the speed -which is very similar to setting an initial velocity-.
来源:https://stackoverflow.com/questions/28262448/player-moves-faster-with-higher-deltatime