UMG and Multiplayer Question

Soooo, As you can see, the widget only shows up for one player(Server). I was able to get it to show up for both at one point(Can;t remember how), but it would still only work for one player(ie reducing health would only be visible on server).

Also I’m creating the widget in my custom PlayerController. I don’t know if that’s bad or not, but I felt that was a good place for now for when I expand and do more.

Any thoughts? I was essentially following the UMG tutorial series. Basically I think I just need to know how to get the correct controller for each person within the widget blueprint?


Are your variables replicated and have you bound your UMG to those variables through the on_repNotify events.

I suggest you watch these tutorials: Blueprint Networking Tutorials

Also remove the getPlayerController from your arsenal when coding multiplayer games … it was designed for single player and split screen only. For multiplayer you need to use the following:

  • Player Controller - use Get Controlled Pawn
  • HUD - use Get Owning Player Controller
  • Widget Blueprint - use Get Owning Player

This has been my experience and I have a fully working networked enabled game with a HUD for a player that has weapons, attributes, loot, and power-ups. 8-}

Actually I just realized I’m getting a failed cast. The second image of the OP. That cast is failing. Any ideas??

I have absolutely no idea why this cast to the pawn is failing. The cast to the controller is working perfectly and I’ve tested it to be sure, but it fails at the pawn.

It works if i plug in playercontroller == 0, but obviously I don’t want that :confused:

PLEASE does anyone know why that is happening???

Use “Get Owning Player Controller” instead of “Get Owning Player” … try this first. 8-}

UE4 Documentation: Get Owning Player Controller - returns a reference to Player Controller.

Edit: Wow dude … give us some time to answer you.

Sorry, I didn’t even realize I basically said the same thing twice haha. Seems like an eternity!!! :smiley:

Alright, I can’t do that because target needs to be HUD and this is all within a Widget, not a HUD Blueprint.

When you create the HUD widget in your PlayerController, you don’t supply it with an Owning Player. Connect it with a reference to self.

When I tried to do that(connect with ref to self) the program would just crash so I would never plug anything it :confused:

That should be fixed in 4.8 (you can work around it in 4.7 by adding a Delay(0) before creating the UI. Also you want to test if it’s a local controller in the blueprint before even attempt to create UI for a player controller. Also make sure to destroy the UI created for the player when the player’s destroy is called.

I’m actually still in 4.7 so ill get that update right now! And try the delay way you mentioned. Thanks!

No problem - make sure to check if local player after the delay.

They delay worked! Thank you! I tried 4.8 but it had long compile times and would crash often. :confused:

Next question if you would care to help me (Probably related to destroying the UI on death)
Other topics said you shouldn’t destroy the UI just hide it (I actually couldn’t even find a way to destroy it)

But how do I update the healthbar to the new pawn that is created? Is it related to needing a OnNotify event like qdelpeche mentioned?

“UMG to those variables through the on_repNotify events” Because I’m kind of unsure on what do do about this. I know how to make the events but I;m not sure what to put into them?