I have a NetworkBehaviour script which contains a SyncVar int. If I check LocalPlayerAuthority on the GameObject, the SyncVar int’s value become “out of control” on the local player.
By “out of control”, this is what I observed in the debug log:
-int is initialized and sync-ed correctly,;
-an instant later hook function gets called on client for about 40 times attempting to change the value to 66, 63 and 65 in a random manner
-sometimes the int is hooked to set consecutively for the same value like 65 for 5 times in a row.
-after a while hook function gets called to set to a larger variety of numbers
-few seconds later since above, hook function stops getting called and the int stopped at the value 179
The only place where I touch this int is OnStartServer() where I set it to 100, and the hook function setting the int to the argument of the hook.
Is this a bug? but looks pretty crazy to be a bug and from what I read about how SyncVar work this seem too strange also no one else seem to be having problem with SyncVar so I’m not sure if I have totally misunderstood something. Any insight is appreciated, thank you.
Do SyncVar work when the GameObject has multiple NetworkBehaviour components attached ( though I don’t recall reading anywhere mentioning it)?
Basically I have 3 scripts on my object which I separate the GameObject’s function into. I have one script which poll player input, one script which give instruction based on the input result and one script (where all SyncVar are supposed to live in) which store game data like current score for the player. I suspect the system do not like my setup…
Those value changes seem pretty weird and random.
Mine do have multiple NetworkBehaviours, but I’m not using the default callbacks. I have one that does basic logic, one that handles controlling and one that changes appearance properties.
I use the Client Message Handlers and RPCs/Commands.
Well in the original script I referred to on topic I only used Start() and regardless the weird behaviour still happened so I don’t think the problem is due to these callbacks. I guess I will file in a bug with a clean project…