Describe the bug
SendTickRate below zero is not handled for NetworkVariable.
To Reproduce
- Create a script with NetworkVariable of any simple type such as a float, bool, double.
- Set the
SendTickRate to below 0.
- Add a handler to OnValueChanged
- Update the NetworkVariable from the server
Actual outcome
Observe the handler being called as fast as it is written to on the connected clients.
Expected outcome
Expected behavior as defined per the documentation.
If you want values to be synced only once (at spawn), the built-in container's send rate can be set to a negative value.
Additional context
Just check the differences between NetworkList.IsDirty and NetworkVariable.IsDirty.
|
/// <summary> |
|
/// Sets whether or not the variable needs to be delta synced |
|
/// </summary> |
|
public void SetDirty(bool isDirty) |
|
{ |
|
m_IsDirty = isDirty; |
|
} |
|
public bool IsDirty() |
|
{ |
|
if (m_DirtyEvents.Count == 0) return false; |
|
if (Settings.SendTickrate == 0) return true; |
|
if (Settings.SendTickrate < 0) return false; |
|
if (NetworkManager.Singleton.NetworkTime - LastSyncedTime >= (1f / Settings.SendTickrate)) return true; |
|
return false; |
|
} |
Describe the bug
SendTickRate below zero is not handled for NetworkVariable.
To Reproduce
SendTickRateto below 0.Actual outcome
Observe the handler being called as fast as it is written to on the connected clients.
Expected outcome
Expected behavior as defined per the documentation.
Additional context
Just check the differences between
NetworkList.IsDirtyandNetworkVariable.IsDirty.com.unity.netcode.gameobjects/com.unity.multiplayer.mlapi/Runtime/NetworkVariable/NetworkVariable.cs
Lines 102 to 108 in ee59d5f
com.unity.netcode.gameobjects/com.unity.multiplayer.mlapi/Runtime/NetworkVariable/Collections/NetworkList.cs
Lines 82 to 89 in ee59d5f