Hi, I’m playing with the XRI Multiplayer sample and using a toggle to hide and show an object works just fine when networked toggle and network objects are added correctly. yet even though i set Broadcast Value On Join in the networked toggle component of the toggle, the current state is not broadcasted to player that join later. i’ve been trying for hours but cant find the problem. am i missing something?
cheers
yes, correct. should toggling objects work with object that are setup with a network object and networked toggle?
cheers
So, my guess is that you are using an RPC to send the networked toggle state.
- RPCs: You should view remote procedure calls as basically being “events” and in reality are just a way to communicate that you want all connected clients to invoke a specific method with the option to pass along parameters. The parameters passed you should view the same way as you would with script… they are temporary values typically passed along in the call stack cache and only persist for the duration of the method being invoked. RPCs are non-persistent events.
- NetworkVariables: You should view NetworkVariables as a way to communicate persisted states. When you make a change to a NetworkVariable the connected clients, if they subscribe to the OnValueChanged callback, can be notified. NetworkVariables are persisted state updates with the option to be associated with an event notification when they change. When a new client joins, the current NetworkVariable states are synchronized and set on the NetworkVariable by the time a NetworkBehaviour invokes the OnNetworkSpawn method.
With this said, you probably need to make that networked value tied to a NetworkVariable and register for the OnValueChanged during OnNetworkSpawn so when it changes you just set the networked toggle to the value of the NetworkVariable.
Let me know if this helps you resolve your issue?