- Home /
Proper way to send variables over the network
Hi, Having a problem with sending player variables across the network using UNET. I have a int variable TeamNum which is a Syncvar. One of the things this variable is used for is to set a color on a part of the character model to show what team they are on. The problem is that when new players join, existing players see their color correctly, but the new player will see the old players as the same color as himself. For example, if there are 2 red players and a blue player joins, the blue player will see blue on each red player, but each red player will see the blue player as blue. What I need is a way for existing players to update their TeamNum to all other players when a new player connects. I have tried a number of things including many variations of Command and RPC calls. I have basic Command and RPC working as I can have it update via a button press, but then only the player who presses the button shares their variable.
SyncVar's should be working here, they are an appropriate way of syncing this kind of data across the network. I suspect the problem lies elsewhere in your code. Could you provide some relevant snippets? The statement "but the new player will see the old players as the same color as himself" makes me suspect that you may be setting all players syncvar variable on new players client, or something like that.
Your answer
Follow this Question
Related Questions
UNET: Flicker when a client moves a non-player object using another non-player-object 1 Answer
Unity multiplayer Animations Over a network etc 1 Answer
UNET OnTriggerEnter called due to placement of Network-GameObjects on Clients 0 Answers
SyncListStruct Not Syncing to Rest of Server! 0 Answers
How to find when the network transform component stops receiving update in UNET ? 0 Answers