#Color sync with Multiplayer Services & Sessions
1 messages · Page 1 of 1 (latest)
For some reference I’m simply trying to sync the color of the images color so that the colors are the same on both the host and client. Right now it shows the hosts color correctly (probably because its defaulted to green) and the clients color is only the same on both a small amount of the time (it randomized between 5 colors so if they both randomize to the same color it looks correct). Both the host and client call the updateui function when the client “joins” to change the session, which is part of the problem but I am not sure how to go about fixing it without breaking the rest.
reference image:
Green is always the host
You should probably use Player Properties for the color
https://docs.unity.com/ugs/en-us/manual/mps-sdk/manual/session-op-client#Add_a_player_property
I am using player properties
my issue is that it does not persist
Ill show that bit
async Task<Dictionary<string,PlayerProperty>> GetPlayerProperties()
{
string playerName = await AuthenticationService.Instance.GetPlayerNameAsync();
string playerColor = GlobalResources.GetRandomColorKey();
PlayerProperty playerNameProperty = new PlayerProperty(playerName, VisibilityPropertyOptions.Member);
PlayerProperty playerColorProperty = new PlayerProperty(playerColor, VisibilityPropertyOptions.Member);
return new Dictionary<string, PlayerProperty>()
{
{ PlayerNamePropertyKey, playerNameProperty },
{ PlayerColorPropertyKey, playerColorProperty },
};
}
Currently im trying the custom network serializer and see if that has any luck 🤷♂️
You don't need to use RPCs. After you set the player properties you need to call session.SaveCurrentPlayerDataAsync()
no fucking way there is just a save function
There is a Player Properties Change event you need to listen for too
Unfortunately, it doesn't tell you which property changed.
you gotta be kidding me
I genuinely just spent like 4 hours on that
im getting rate limited now but it did update
So how can I update it for everyone without getting rate limited
the event?
The local player can update themselves.
Yea, then they just listen for the event for changes
Wait that event fires every time any property is changed?
I cant stop getting rate limited all because I change it twice like
Only when you call SaveCurrentPlayerDataAsync(), so make all your changes, then call it.