fix falling-on-pause bug
The issue happened because of not resetting lastTick: The lastTick is stored to calculate movement speed independent of frame rate. When paused, the delta is calculated with the time before the pause, so it gets huge and results in high velocity values that are used to calculate how far the player moved.
This commit is contained in:
parent
e4e3953734
commit
43e8242619
1 changed files with 4 additions and 1 deletions
|
@ -75,7 +75,10 @@ const move = (thisTick: number): void => {
|
|||
animationFrame = requestAnimationFrame(move)
|
||||
|
||||
// do nothing when paused
|
||||
if (paused.value) return
|
||||
if (paused.value) {
|
||||
lastTick = thisTick // reset tick, to avoid huge tickDelta
|
||||
return
|
||||
}
|
||||
|
||||
const tickDelta = thisTick - lastTick
|
||||
lastTimeUpdate += tickDelta
|
||||
|
|
Loading…
Add table
Reference in a new issue