x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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

Product Version: UE 4.19
Tags:
more ▼

asked Jun 23 '18 at 03:29 AM in Blueprint Scripting

avatar image

gon.
44 2 9 10

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

3 answers: sort voted first

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.

more ▼

answered Jun 23 '18 at 06:04 AM

avatar image

mightyenigma
3.8k 18 20 20

avatar image gon. Jun 23 '18 at 01:23 PM

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

avatar image mightyenigma Jun 23 '18 at 01:58 PM

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.

avatar image gon. Jun 23 '18 at 02:34 PM

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?

avatar image mightyenigma Jun 23 '18 at 05:55 PM

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)

avatar image gon. Jun 24 '18 at 02:26 AM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Jun 24 '18 at 06:10 AM

avatar image

mightyenigma
3.8k 18 20 20

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.alt text

more ▼

answered Jun 25 '18 at 08:47 PM

avatar image

gon.
44 2 9 10

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question