I’m trying to implement a classic Health bar in a gameplay UI. I got it working on the server but not on the client. In the UUserWidget the Health percentage is updated like supposed but not the Health bar. I tried a lot of things and I also tried in blueprint with the same result.
This is my cpp UUserWidget code (the function is called by the player controller and the log report the good percentage for both server and client)
I tried to replicate the variable or not and I tried to directly pass the Health percentage to the UI but I got always the same result the variable is updated but not the Progress Bar. This is not the first time I created multiplayer UI but the first I use progress bar in multiplayer maybe it is different than other widget object. Thanks for your help!
I use print string in the blueprint version of the widget and it print on the screen the client number and the variable at each time the update is called. The server call the client function so I was thinking this is the good way too do. In c++ I use HasAuthority to set the variable on the server and the health percentage too then I call the client function with the server by passing the percentage in parameter.
Yesterday I rebuild the same code in a new project and I got it working the first time I don’t really understand what can I have done wrong in this version. I still have some difficulties with the subtleties of multiplayer programming.
It may have nothing to do with multiplayer. Could it just be the way the progress bar is hooked up? Do you have multiple. Try just setting that value to increase each frame locally and see if that’s the issue.
I finally got it working . In blueprint I called directly the Controller Interface after setting up the variable and it work well but in cpp, I had to add another client function and call it from the OnTakeDamage Event.
This was the working blueprint version: