mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
fix: #3588 NetworkTransform OnTeleport doesn't call Reset() anymore, causing NetworkTransformReliable's delta compression to get out of sync before
This commit is contained in:
parent
a432b7f43d
commit
631b8e0eac
@ -313,13 +313,22 @@ void RpcReset()
|
|||||||
// common Teleport code for client->server and server->client
|
// common Teleport code for client->server and server->client
|
||||||
protected virtual void OnTeleport(Vector3 destination)
|
protected virtual void OnTeleport(Vector3 destination)
|
||||||
{
|
{
|
||||||
// reset any in-progress interpolation & buffers
|
|
||||||
Reset();
|
|
||||||
|
|
||||||
// set the new position.
|
// set the new position.
|
||||||
// interpolation will automatically continue.
|
// interpolation will automatically continue.
|
||||||
target.position = destination;
|
target.position = destination;
|
||||||
|
|
||||||
|
// reset interpolation to immediately jump to the new position.
|
||||||
|
// do not call Reset() here, this would cause delta compression to
|
||||||
|
// get out of sync for NetworkTransformReliable because NTReliable's
|
||||||
|
// 'override Reset()' resets lastDe/SerializedPosition:
|
||||||
|
// https://github.com/MirrorNetworking/Mirror/issues/3588
|
||||||
|
// because client's next OnSerialize() will delta compress,
|
||||||
|
// but server's last delta will have been reset, causing offsets.
|
||||||
|
//
|
||||||
|
// instead, simply clear snapshots.
|
||||||
|
serverSnapshots.Clear();
|
||||||
|
clientSnapshots.Clear();
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// what if we still receive a snapshot from before the interpolation?
|
// what if we still receive a snapshot from before the interpolation?
|
||||||
// it could easily happen over unreliable.
|
// it could easily happen over unreliable.
|
||||||
@ -329,14 +338,23 @@ protected virtual void OnTeleport(Vector3 destination)
|
|||||||
// common Teleport code for client->server and server->client
|
// common Teleport code for client->server and server->client
|
||||||
protected virtual void OnTeleport(Vector3 destination, Quaternion rotation)
|
protected virtual void OnTeleport(Vector3 destination, Quaternion rotation)
|
||||||
{
|
{
|
||||||
// reset any in-progress interpolation & buffers
|
|
||||||
Reset();
|
|
||||||
|
|
||||||
// set the new position.
|
// set the new position.
|
||||||
// interpolation will automatically continue.
|
// interpolation will automatically continue.
|
||||||
target.position = destination;
|
target.position = destination;
|
||||||
target.rotation = rotation;
|
target.rotation = rotation;
|
||||||
|
|
||||||
|
// reset interpolation to immediately jump to the new position.
|
||||||
|
// do not call Reset() here, this would cause delta compression to
|
||||||
|
// get out of sync for NetworkTransformReliable because NTReliable's
|
||||||
|
// 'override Reset()' resets lastDe/SerializedPosition:
|
||||||
|
// https://github.com/MirrorNetworking/Mirror/issues/3588
|
||||||
|
// because client's next OnSerialize() will delta compress,
|
||||||
|
// but server's last delta will have been reset, causing offsets.
|
||||||
|
//
|
||||||
|
// instead, simply clear snapshots.
|
||||||
|
serverSnapshots.Clear();
|
||||||
|
clientSnapshots.Clear();
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// what if we still receive a snapshot from before the interpolation?
|
// what if we still receive a snapshot from before the interpolation?
|
||||||
// it could easily happen over unreliable.
|
// it could easily happen over unreliable.
|
||||||
|
@ -405,6 +405,9 @@ static void RewriteHistory(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reset state for next session.
|
||||||
|
// do not ever call this during a session (i.e. after teleport).
|
||||||
|
// calling this will break delta compression.
|
||||||
public override void Reset()
|
public override void Reset()
|
||||||
{
|
{
|
||||||
base.Reset();
|
base.Reset();
|
||||||
|
Loading…
Reference in New Issue
Block a user