Hello everyone! I have been trying to figure this out for a long, long time and I am running out of ideas so I figured I would try the forums to see what people think. Sorry if this is totally a bad place for this, I have been having no luck at AnswerHub.
I have a widget with health bars created inside my MainController BP and it works fine on the server, however on the clients the UMG bars are not showing the health properly. The widgets appear, but they are not being filled.
Have you tried adding an actor/pawn var to the UMG and setting it to the owner pawn when you create the widget. That way, you wouldn’t call get owning player->get owning pawn. You would reference the pawn directly from the var in the UMG. It may work…Let me know.
Now after I use the server to host the game, without doing anything the UMG widget on the client now appears as if it was working properly (it looks exactly like this http://i.imgur.com/iItzaQa.png) But when I go to join the server, it goes back to looking like this http://i.imgur.com/LmafVss.png
So it’s like something is overriding the UMG widget or something, but I thought thats what checks like “Is locally Controlled” fixed?
Hello Timetravel, do you spawn the characters in manually using a Spawn Actor From Class node somewhere?
If you don’t, you probably should; that worked for me.
When spawning an Actor draw the UI from his blueprint using the Create Widget node. This way every pawn has it’s own ‘instance’ of the widget.
Then you simply bind the health value to the progress bar, and then it should work.
1 - Create a Blueprint Interface, give it a function with 2 outputs: currentHealth and maxHealth.
2 - Go into your characters blueprint and in the Class Settings under Interfaces add the previously created Blueprint Interface.
3 - Then go to your widget and in its Graph tab, open the Class Settings and also add the Blueprint Interface there.
4 - Go back to your Character blueprint and open the function that you created in step 1 (this became accessible in your Character Blueprint when you added the interface in Class Settings)
5 - Create two float variables: currentHealth and maxHealth and connect them to the corresponding function outputs also called currentHealth and maxHealth.
6 - Now go to your widget and create a binding for the percentage of the healthbar. Name it anything you like.
7 - In the binding, place a Get Player Pawn node, drag off of it and get the function you created in step 1 with (Message) behind it.
8 - You should be able to drag off of that and get currentHealth and maxHealth. Divide currentHealth by maxHealth and put the result as the percentage for the Progress bar.
I looked at the debug inside the designer window of my widget and I only see one instance of the widget BP on the client side and two instances on the server side.