Skip to content

Commit 8852294

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

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Assets/Mirror/Components/NetworkTransform/NetworkTransformReliable.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,26 @@ static void RewriteHistory(
445445
);
446446
}
447447

448+
// modify base OnTeleport to NOT reset lastDe/Serialized,
449+
// otherwise delta serialization breaks on teleport.
450+
protected override void OnTeleport(Vector3 destination)
451+
{
452+
// set the new position.
453+
// interpolation will automatically continue.
454+
target.position = destination;
455+
456+
// reset interpolation to immediately jump to the new position.
457+
// do not call Reset() here, this would cause delta compression to
458+
// get out of sync for NetworkTransformReliable because NTReliable's
459+
// 'override Reset()' resets lastDe/SerializedPosition:
460+
// https://github.com/MirrorNetworking/Mirror/issues/3588
461+
// because client's next OnSerialize() will delta compress,
462+
// but server's last delta will have been reset, causing offsets.
463+
//
464+
// instead, simply clear snapshots.
465+
base.ResetState(); // ! OVERWRITE ! only call base.ResetState, don't reset deltas!
466+
}
467+
448468
// reset state for next session.
449469
// do not ever call this during a session (i.e. after teleport).
450470
// calling this will break delta compression.

0 commit comments

Comments
 (0)