#Color sync with Multiplayer Services & Sessions

1 messages · Page 1 of 1 (latest)

dusk zenith
#

Okay I'm totally stumped. All I am trying to do is sync up a simple color with sessions (Multiplayer Services) and I can't even do that. I am just going to share my code because I have searched around forever and I have no clue what I am doing wrong.

SyncLobbyColor

LobbyUI

Would love some help. Thanks.

#

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

lapis pagoda
dusk zenith
#

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 🤷‍♂️

lapis pagoda
#

You don't need to use RPCs. After you set the player properties you need to call session.SaveCurrentPlayerDataAsync()

dusk zenith
#

no fucking way there is just a save function

lapis pagoda
#

There is a Player Properties Change event you need to listen for too

#

Unfortunately, it doesn't tell you which property changed.

dusk zenith
#

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?

lapis pagoda
#

The local player can update themselves.

#

Yea, then they just listen for the event for changes

dusk zenith
lapis pagoda