Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Additional documentation and release notes are available at [Multiplayer Documen


### Changed

- Improve performance of `NetworkRigidbodyBase`. (#3906)

### Deprecated

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public abstract class NetworkRigidbodyBase : NetworkBehaviour
#endif


private NetworkManager m_LocalNetworkManager;
// Used to cache the authority state of this Rigidbody during the last frame
private bool m_IsAuthority;

Expand Down Expand Up @@ -971,7 +972,7 @@ protected override void OnOwnershipChanged(ulong previous, ulong current)
/// </remarks>
internal void UpdateOwnershipAuthority()
{
if (NetworkManager.DistributedAuthorityMode)
if (m_LocalNetworkManager.DistributedAuthorityMode)
{
// When in distributed authority mode, always use HasAuthority
m_IsAuthority = HasAuthority;
Expand All @@ -980,7 +981,7 @@ internal void UpdateOwnershipAuthority()
{
if (NetworkTransform.IsServerAuthoritative())
{
m_IsAuthority = NetworkManager.IsServer;
m_IsAuthority = m_LocalNetworkManager.IsServer;
}
else
{
Expand All @@ -994,11 +995,16 @@ internal void UpdateOwnershipAuthority()
}
}

internal override void InternalOnNetworkPreSpawn(ref NetworkManager networkManager)
{
m_LocalNetworkManager = networkManager;
}

/// <inheritdoc />
public override void OnNetworkSpawn()
{
m_TickFrequency = 1.0f / NetworkManager.NetworkConfig.TickRate;
m_TickRate = NetworkManager.NetworkConfig.TickRate;
m_TickFrequency = 1.0f / m_LocalNetworkManager.NetworkConfig.TickRate;
m_TickRate = m_LocalNetworkManager.NetworkConfig.TickRate;
UpdateOwnershipAuthority();
}

Expand Down