#Changing Player color
1 messages · Page 1 of 1 (latest)
yes, network variable is set on the owning player for sure
Is there a way to print the network variable of other clients?
Yea. It's just NetworkVariable.Value. now on spawn the OnValueChanged callback will not be called. You will just have to set the renderer to that current value
When you're saying "on spawn the OnValueChanged callback will not baclled", do you refer that it will not be called on the spawn of the client or the host?
Everything is working fine in my case except for when the host changes the color before client connects. But after the client connects and client changes color, both client and host can see it.
I tried copy-pasting the renderer color assignment code into OnEnable, as well as Update with no luck. I'll try out a few more things
For any late joining client. The network variable will be set correctly for any existing players but their OnValueChanged event would not be called when they spawn in on the new client
Then what would the solution be?
Truth be told, I guided myself from this tutorial
https://github.com/DapperDino/Unity-Multiplayer-Tutorials/blob/main/Assets/Tutorials/PlayerNames/Scripts/TeamPlayer.cs
But for him, it seems to work https://www.youtube.com/watch?v=iQDGLaSI3Cg&ab_channel=DapperDino
I guess the youtube video is written in the old API, while I'm using NGO. His code is updated to use NGO, but it's unclear to me if it's also tested for late-joining clients to work
Putting renderer.matierial.color = networkvariable.value or whatever into OnNetworkSpawn should work