Skip to content

Commit 11c5ff0

Browse files
committed
chore: network manager field instead of property
1 parent 7c515b3 commit 11c5ff0

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

com.unity.netcode.gameobjects/Runtime/Components/NetworkRigidBodyBase.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public abstract class NetworkRigidbodyBase : NetworkBehaviour
5252
#endif
5353

5454

55+
private NetworkManager m_LocalNetworkManager;
5556
// Used to cache the authority state of this Rigidbody during the last frame
5657
private bool m_IsAuthority;
5758

@@ -971,7 +972,7 @@ protected override void OnOwnershipChanged(ulong previous, ulong current)
971972
/// </remarks>
972973
internal void UpdateOwnershipAuthority()
973974
{
974-
if (NetworkManager.DistributedAuthorityMode)
975+
if (m_LocalNetworkManager.DistributedAuthorityMode)
975976
{
976977
// When in distributed authority mode, always use HasAuthority
977978
m_IsAuthority = HasAuthority;
@@ -980,7 +981,7 @@ internal void UpdateOwnershipAuthority()
980981
{
981982
if (NetworkTransform.IsServerAuthoritative())
982983
{
983-
m_IsAuthority = NetworkManager.IsServer;
984+
m_IsAuthority = m_LocalNetworkManager.IsServer;
984985
}
985986
else
986987
{
@@ -994,11 +995,16 @@ internal void UpdateOwnershipAuthority()
994995
}
995996
}
996997

998+
internal override void InternalOnNetworkPreSpawn(ref NetworkManager networkManager)
999+
{
1000+
m_LocalNetworkManager = networkManager;
1001+
}
1002+
9971003
/// <inheritdoc />
9981004
public override void OnNetworkSpawn()
9991005
{
1000-
m_TickFrequency = 1.0f / NetworkManager.NetworkConfig.TickRate;
1001-
m_TickRate = NetworkManager.NetworkConfig.TickRate;
1006+
m_TickFrequency = 1.0f / m_LocalNetworkManager.NetworkConfig.TickRate;
1007+
m_TickRate = m_LocalNetworkManager.NetworkConfig.TickRate;
10021008
UpdateOwnershipAuthority();
10031009
}
10041010

0 commit comments

Comments
 (0)