Skip to content

Commit e5f664d

Browse files
committed
fix: Mirror NetworkTransformHybrid OnTeleport breaking delta compression by resetting last de/serialized
1 parent 8852294 commit e5f664d

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Assets/Mirror/Components/NetworkTransform/NetworkTransformHybrid.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,26 @@ static void RewriteHistory(
478478
);
479479
}
480480

481+
// modify base OnTeleport to NOT reset lastDe/Serialized,
482+
// otherwise delta serialization breaks on teleport.
483+
protected override void OnTeleport(Vector3 destination)
484+
{
485+
// set the new position.
486+
// interpolation will automatically continue.
487+
target.position = destination;
488+
489+
// reset interpolation to immediately jump to the new position.
490+
// do not call Reset() here, this would cause delta compression to
491+
// get out of sync for NetworkTransformReliable because NTReliable's
492+
// 'override Reset()' resets lastDe/SerializedPosition:
493+
// https://github.com/MirrorNetworking/Mirror/issues/3588
494+
// because client's next OnSerialize() will delta compress,
495+
// but server's last delta will have been reset, causing offsets.
496+
//
497+
// instead, simply clear snapshots.
498+
base.ResetState(); // ! OVERWRITE ! only call base.ResetState, don't reset deltas!
499+
}
500+
481501
// reset state for next session.
482502
// do not ever call this during a session (i.e. after teleport).
483503
// calling this will break delta compression.

0 commit comments

Comments
 (0)