mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 11:00:32 +00:00
fix(Prediction): InsertCorrection would produce NaN multipliers, spreading through prediction code
This commit is contained in:
parent
febcce9513
commit
df918ecf9f
@ -121,7 +121,10 @@ public static void InsertCorrection<T>(
|
||||
//
|
||||
double previousDeltaTime = after.timestamp - before.timestamp; // 3.0 - 1.0 = 2.0
|
||||
double correctedDeltaTime = after.timestamp - corrected.timestamp; // 3.0 - 2.5 = 0.5
|
||||
double multiplier = correctedDeltaTime / previousDeltaTime; // 0.5 / 2.0 = 0.25
|
||||
|
||||
// fix multiplier becoming NaN if previousDeltaTime is 0:
|
||||
// double multiplier = correctedDeltaTime / previousDeltaTime;
|
||||
double multiplier = previousDeltaTime != 0 ? correctedDeltaTime / previousDeltaTime : 0; // 0.5 / 2.0 = 0.25
|
||||
|
||||
// recalculate 'after.delta' with the multiplier
|
||||
after.AdjustDeltas((float)multiplier);
|
||||
|
Loading…
Reference in New Issue
Block a user