Download

Problem with UMG Widgets in Network mode.

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.

This is what it looks like on the server when working properly: http://i.imgur.com/lJVjURA.png

This is what it looks like when it’s not working properly on the client: http://i.imgur.com/LmafVss.png

This is the order of things being called:

Inside my PlayerController: http://i.imgur.com/yGvAZ7Q.png

This is the setupUI function itself: http://i.imgur.com/yNFDGux.png

And this is the function bound to the UMG widget I am creating: http://i.imgur.com/BZxwe9U.png

I can provide more information about the game if needed, thank you!

Project files: https://drive.google.com/file/d/0B2m7pbHo7FYPTnl6ODAwd3pJNTg/view?usp=sharing

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.

I tried this: http://i.imgur.com/P5aBTBv.png

But the result is the same. However I figured I should also mention other things I noticed that seem odd.

This is what the server UMG looks like when I start the game: http://i.imgur.com/iItzaQa.png

This is what the client looks like: http://i.imgur.com/eTF2oGQ.png

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?

I also tried doing this: http://i.imgur.com/qhvYrs0.png

as recommended here: Problem with UMG / Networking 4.5 - UE4 AnswerHub

But the issue is the same… I am really running out of ideas :frowning:

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. :slight_smile:

If that doesn’t work try the following:

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.

Let me know if this works. :slight_smile:

Yeah I already do this.

I also tried the method you suggested but this time the bars just remain empty. I’m going to upload my project soon…

This sounds stupid but: did you do some debug output, are you really sure the client player’s character health is set properly?

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.

I have uploaded my project files here:

https://drive.google.com/file/d/0B2m7pbHo7FYPTnl6ODAwd3pJNTg/view?usp=sharing