3D widget progress bar replication to client

Hello,

I have made a widget with a progress bar that updates by player action. The widget reads float variables that are updated and stored in GameState. This works great for the server, but nothing updates to the client. The client can update the progress bar for the server though by doing the same action.

The 3D widget is stored in an Actor Blueprint which is set to replicate. For the past 2 days I have tried googling about this, but I have yet to find a solution. My assumption is that whatever float variable I have stored in GameState should replicate to all players as this has worked so far. But for whatever reason it doesn’t update the 3D widget for clients.

This is all I have to do for the progress bar to update for the server. What should I do to update it to the clients too?

Thanks in advance.

Hey there @Saintdoot! Welcome to the community! First I’d check to see if the variables are being changed at all. The gamestate is a bit different when it comes to replication. This thread might (or might not) help:

Hey.

The values are changed in GameState. The values don’t change by direct player action. I have a collision box blueprint that checks to see if specific objects (cubes at the moment) are overlapping with the collision box. If it is, then the collision box reads the value of the item and adds it to a variable in GameState. I know the values update, because I have a print string that shows the total value of the variable. If client increases it by 1 and then server increases it by 2 the print string reads 3.

The post you linked did have useful information though, so thank you for that. But in this case, a client is not trying to change the value in GameState through a widget.

UPDATE: I changed the way the widget updates the progress bar. I made the change logic inside the 3D widget blueprint using the Set Percentage function. Unfortunately the progress bar still doesn’t update if I calculate the percentage by casting to GameState and getting the values from there. If I create two float values inside the blueprint and set the progress bar percentage using those, then it does update to the client too.

So now the problem is how to update those temporary values using the actual values from GameState.

UPDATE 2: My assumption was incorrect: just because the values are stored in GameState doesn’t mean the client is aware of them updating.

I changed where the values are stored. Now instead of GameState they are stored in the collision box blueprint that reads the value of the item that is thrown in it. Then in the 3D widget blueprint I read these values by casting to the collision box blueprint and use them to calculate the progress bar percentage. This method replicates the progress bar updating to clients also.

I have couple of new problems now, but they seem easier to deal with.

1 Like