-
-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SyncVar OnChange prev value incorrect on clients #800
Comments
This is intended behavior as clientHost. We moved away from having separate values for clientHost as it was creating more complex code with very little benefit. You can switch to stable mode to get the old syncVars back but at some point this will become the new default. |
As stated above it's normal for 'asServer false' to show the same value when clientHost, in the newest SyncTypes. ClientOnly seeing the same values however was an error. The resolution is to go into SyncVar.cs and find this bit... if (!base.NetworkManager.IsServerStarted)
UpdateValues(nextValue);
T prev = _value;
InvokeOnChange(prev, nextValue, asServer: false); Replace with this (moving prev above if check) T prev = _value;
/* If also server do not update value.
* Server side has say of the current value. */
/* Only update value if not server. We do not want
* clientHost overwriting servers current with what
* they just received.*/
if (!base.NetworkManager.IsServerStarted)
UpdateValues(nextValue);
InvokeOnChange(prev, nextValue, asServer: false); Resolved in 4.5.3 |
- Fixed PreciseTick.Percent value being 0 instead of 1 when checked during a ticked frame. - Fixed condition where NetworkTransform may not unsubscribe from events on client or server stop. - Fixed code stripping not working in Unity 2022+ (#798). - Fixed SyncVar OnChange method having incorrect previous value for clientOnly (#800). - Fixed foreach enumerator in SyncList (#799). - Added PreciseTick.GetUnsetValue. - Fixed preciseTick.Subtract improperly calculating percentages. - Fixed incorrect parsing of null arrays (#802). - Added NetworkObject.PreventDespawnOnDisconnect to prevent objects from despawning when the owner disconnects.
General
Unity version: Unity 6 (6000.0.23f1)
Fish-Networking version: 4.5.2
Discord link: https://discord.com/channels/424284635074134018/1034477094731784302/1299363640188731393
Description
When a SyncVar is changed the OnChange event triggers with the previous value being the same as the next value. This only happens with asServer as false. You may need to create a blank project to replicate this as it was not happening in my old testing project.
Replication
Steps to reproduce the behavior:
K
key a few times to change the SyncVarExpected behavior
It should be the correct previous value like happens when asServer is true.
Screenshot

Example Package
SyncVarIssue.zip
The text was updated successfully, but these errors were encountered: