Talent/Skill Tree multiplayer replication best ways

Hello!

How would you make somekind of Talent/Skills Tree in a multiplayer game and replicate variables across the network to all clients? I have been using Multicast/RunonServer System inside Character BP and really works fine but seems to be too complex when you have over 100 variables.

Also I read somewhere Multicasts abuse is a mistake and should be only used for simple things like small events or sounds. Anyway Multicast System seems to break when a new player logs in and join the server but I could fix that.

Have been checking OnRep/RepNotify and PlayerState and would like to know which ways you think is better and why.

Thank you

the most performant thing I know is to mark a variable as replicated and send a client to server RPC when you want to change it. It will replicate to all clients when the system feels like it. If the client is not within range for the change to be relevant to them, they will miss any effects triggered by the changep. but thats part of why it is so performant.

Multicasts force something to happen inmediately across all clients rather than letting it dish out the info as it deems optimal.

Repnotifies dont necessarily happen immediately but they wait until the replicated actor becomes relevant and then trigger the notify function.

What about using PlayerState?
As far as I know, PlayerState are replicated and unique for each player, so the problem I have with Multicast (variables got reset for everybody with each new player logs in and joins the server session) could be fixed because all variables inside PlayerState from all client or players are loaded automatically by the new player.

Is that right?
Could this be a better way to follow and solve my specific problem?
Maybe set all variables from CharacterBP to PlayerState.

Thnx mightyenigma

Absolutely. In networked multiplayer the PlayerState is the place to store information about the player that meets the following needs:

  1. Replicates from Server to all Clients (if the variable is marked to Replicate).
  2. Uniquely identifiable across all devices on the network (playercontroller won’t do that).
  3. Survives pawn destruction.

If someone join the server with ie two more players inside with their own values on that variables stored into the PlayerState, should I do something to get all vars from the rest of the players and let the new player knows it or its not necessary becacuse its automatically done?

The mechanic is making a custom event Run on Server Reliable and set there the variable to PlayerState and its all done?

It depends what you want to happen. It is enough to change a replicated variable on the server and then it will automatically tell all the Clients’ copy of the same Playerstate to have that value.

But if you needed something to happen, not just have them know the value (like you triggered and elevator to move up to the top floor) Then you should use a repnotify so the players who joined AFTER the elevator moved still have it triggered to move (although the elevator info would not be stored on a playerstate. Probaly level blueprint instead)

Thanks a lot for all this info. Ill check it tomorrow with another computer.
Will it work with Material Instance or just simple variables like float integers and so?

Was thinking about somekind of random skin function and use PlayerState. I would make it work with floats and asign each value to a Material Instance but maybe I could replicate the variable itself.

If you want to change things anout a material during execution of the game you need a Material Dynamic Instance variable and set it to an MDI you create at runtime using the component it is applied to and the material slot.

I havent figured out if MDIs replicate very well or not but you can make sure the material they are made from has parameter nodes and you can change the values of those params at runtime via MDIs, and the values you feed into the params can be supplied by replicated vars on the playerinfo or pawn.

but maybe you canjust replicate the MDI. If you can get that to work then let me know.

For what I want, just store a variable with an independent value associated to each player and loaded always when a new player joins the session with the possibility to let the value keep alive after player death, I decided just to use PlayerState, create a replicated variable and use a custom event Run on Server to set it up in x+2 each time a button is pressed.

Ill continue for now this logic, seems to work fine.
Thanks for all and Ill take a look later about the logic for the RandomSkinFunction.