updateclient split

This commit is contained in:
mischa 2024-10-18 12:33:59 +02:00
parent de32fc785d
commit 6ad2d332bd

View File

@ -494,7 +494,7 @@ protected virtual void OnServerToClientDeltaSync(byte baselineTick, Vector3? pos
));
}
// update //////////////////////////////////////////////////////////////
// update server ///////////////////////////////////////////////////////
bool baselineDirty = true;
void UpdateServerBaseline(double localTime)
{
@ -642,14 +642,9 @@ void UpdateServer()
UpdateServerInterpolation();
}
void UpdateClient()
// update client ///////////////////////////////////////////////////////
void UpdateClientBroadcast()
{
// client authority, and local player (= allowed to move myself)?
if (IsClientWithAuthority)
{
// https://github.com/vis2k/Mirror/pull/2992/
if (!NetworkClient.ready) return;
// send to server each 'sendInterval'
// NetworkTime.localTime for double precision until Unity has it too
//
@ -686,9 +681,8 @@ void UpdateClient()
lastClientSendTime = NetworkTime.localTime;
}
}
// for all other clients (and for local player if !authority),
// we need to apply snapshots from the buffer
else
void UpdateClientInterpolation()
{
// only while we have snapshots
if (clientSnapshots.Count > 0)
@ -711,6 +705,23 @@ void UpdateClient()
ApplySnapshot(computed);
}
}
void UpdateClient()
{
// client authority, and local player (= allowed to move myself)?
if (IsClientWithAuthority)
{
// https://github.com/vis2k/Mirror/pull/2992/
if (!NetworkClient.ready) return;
UpdateClientBroadcast();
}
// for all other clients (and for local player if !authority),
// we need to apply snapshots from the buffer
else
{
UpdateClientInterpolation();
}
}
void Update()