Widget Mutliplayer Beginner

Hello, I came to ask for help with a problem.
I have currently created a widget that will represent the progression of the level.
It’s a small multi-game and I would like this widget to be updated for all clients.
So I have my RadiationIncrement function which adds 5% when I pick up a specific item.
This function is located on the game state and has its notify rep with nothing inside.
it is called from my actor class which and my object which I pick up.
I have my widget which is created on my beginplayer in my BP player.
logically, given that my radiation current variable is in rep notify, it should be updated on all clients from the game state, right? how to remedy this? only the players who pick it up have their widget updated and not the others



no one has any idea ?

Hi, I’m not sure I understood the question, but if you want Radiation Current to increase for everyone if anyone picks something up, then make sure you call RadiationIncrement on the server and on the server only.

Also there is then no reason for RadiationIncrement being a Multicast, if you only want to execute that event on the server and not on the clients. If a client calls a Multicast, only that client will execute it (which I guess is the problem you are currently having), so if you meant for the client to request the server executes something, then you need a RunOnServer RPC for that and call it from an actor that is owned by the calling client (i.e. won’t work in the GameState).

Hello, thank you for your response, so concretely I forget my game state and I create a variable in my bp player current radiation? Who do I call when I pick up my items? If you have time can you illustrate or draw an example? because I’m not sure I understood correctly.

What you could do:

(-) When a client wants to pick up an item, call a RunOnServer event and do the pick up logic on the server. You can have that RunOnServer event inside the bp player (I assume bp player is a pawn or character, those should be automatically owned by the client if possessed, otherwise you can set the owner from the server).
(-) Then on the server, you change the current radiation variable inside the GameState
(-) Since RadiationCurrent is replicated, it will be updated on the clients and then GetText should work (if you call GetText on tick, if you want it event driven you could call GetText from the repnotify)

Thank you very much for your help it worked, thank you for taking the time I wish you the best

:+1:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.