@@ -434,6 +434,10 @@ internal NetworkVariable<NetworkTransformState> ReplicatedNetworkState
434
434
}
435
435
}
436
436
437
+ // Used by both authoritative and non-authoritative instances.
438
+ // This represents the most recent local authoritative state.
439
+ private NetworkTransformState m_LocalAuthoritativeNetworkState ;
440
+
437
441
private ClientRpcParams m_ClientRpcParams = new ClientRpcParams ( ) { Send = new ClientRpcSendParams ( ) } ;
438
442
private List < ulong > m_ClientIds = new List < ulong > ( ) { 0 } ;
439
443
@@ -446,16 +450,17 @@ internal NetworkVariable<NetworkTransformState> ReplicatedNetworkState
446
450
private BufferedLinearInterpolator < float > m_ScaleZInterpolator ;
447
451
private readonly List < BufferedLinearInterpolator < float > > m_AllFloatInterpolators = new List < BufferedLinearInterpolator < float > > ( 6 ) ;
448
452
449
- // Used by both authoritative and non-authoritative instances.
450
- // This represents the most recent local authoritative state.
451
- private NetworkTransformState m_LocalAuthoritativeNetworkState ;
452
-
453
453
// Used by integration test
454
454
private NetworkTransformState m_LastSentState ;
455
455
456
456
// Used by the non-authoritative side to handle ending extrapolation
457
457
private NetworkTransformState m_LastReceivedState ;
458
458
459
+ internal NetworkTransformState GetLastSentState ( )
460
+ {
461
+ return m_LastSentState ;
462
+ }
463
+
459
464
/// Calculated when spawned, this is used to offset a newly received non-authority side state by 1 tick duration
460
465
/// in order to end the extrapolation for that state's values.
461
466
/// Example:
@@ -465,11 +470,6 @@ internal NetworkVariable<NetworkTransformState> ReplicatedNetworkState
465
470
/// <see cref="OnNetworkStateChanged"/> to see how NetworkState-A-Post doesn't get excluded/missed
466
471
private double m_TickFrequency ;
467
472
468
- internal NetworkTransformState GetLastSentState ( )
469
- {
470
- return m_LastSentState ;
471
- }
472
-
473
473
/// <summary>
474
474
/// This will try to send/commit the current transform delta states (if any)
475
475
/// </summary>
@@ -487,8 +487,12 @@ protected void TryCommitTransformToServer(Transform transformToCommit, double di
487
487
return ;
488
488
}
489
489
490
- // Either updates the authority or sends and RPC to the authoritative instance
491
- if ( ! TryUpdateAuthority ( transformToCommit ) )
490
+ // If we are authority, update the authoritative state
491
+ if ( CanCommitToTransform )
492
+ {
493
+ UpdateAuthoritativeState ( transform ) ;
494
+ }
495
+ else // Non-Authority
492
496
{
493
497
// We are an owner requesting to update our state
494
498
if ( ! m_CachedIsServer )
@@ -1017,7 +1021,7 @@ private void OnNetworkStateChanged(NetworkTransformState oldState, NetworkTransf
1017
1021
1018
1022
// Set the current local tick and wait until the next tick before we end
1019
1023
// this state's extrapolation.
1020
- m_LastReceivedState . EndExtrapolationTick = NetworkManager . LocalTime . Tick ;
1024
+ m_LastReceivedState . EndExtrapolationTick = NetworkManager . LocalTime . Tick + 2 ;
1021
1025
}
1022
1026
}
1023
1027
@@ -1262,13 +1266,8 @@ private void SetStateServerRpc(Vector3 pos, Quaternion rot, Vector3 scale, bool
1262
1266
/// If it is not authority it exits early returning false.
1263
1267
/// </summary>
1264
1268
/// <param name="transformSource">transform to be updated</param>
1265
- private bool TryUpdateAuthority ( Transform transformSource )
1269
+ private void UpdateAuthoritativeState ( Transform transformSource )
1266
1270
{
1267
- if ( ! CanCommitToTransform )
1268
- {
1269
- return false ;
1270
- }
1271
-
1272
1271
// If our replicated state is not dirty and our local authority state is dirty, clear it.
1273
1272
if ( ! ReplicatedNetworkState . IsDirty ( ) && m_LocalAuthoritativeNetworkState . IsDirty )
1274
1273
{
@@ -1278,7 +1277,6 @@ private bool TryUpdateAuthority(Transform transformSource)
1278
1277
}
1279
1278
1280
1279
TryCommitTransform ( transformSource , m_CachedNetworkManager . LocalTime . Time ) ;
1281
- return true ;
1282
1280
}
1283
1281
1284
1282
/// <inheritdoc/>
@@ -1295,11 +1293,12 @@ protected virtual void Update()
1295
1293
return ;
1296
1294
}
1297
1295
1298
- // Either updates the authority or handle:
1299
- // - Non-authoritative side interpolation
1300
- // - Applying the current authoritative state
1301
- // - Stop extrapolating the current state (if it is 1 tick after it was received)
1302
- if ( ! TryUpdateAuthority ( transform ) )
1296
+ // If we are authority, update the authoritative state
1297
+ if ( CanCommitToTransform )
1298
+ {
1299
+ UpdateAuthoritativeState ( transform ) ;
1300
+ }
1301
+ else // Non-Authority
1303
1302
{
1304
1303
if ( Interpolate )
1305
1304
{
0 commit comments