Download

Setting up UMG for a listen server, problems interacting with actors

Firstly, I followed this tutorial for setting up an inventory system and vitals GUI. I hadn’t touched UMG previously so this was supposed to be a learning experience above all else.

The tutorial was designed with single player in mind. I’ve been trying to adapt it for use in multiplayer.

My first problem I believe is setting up the GUI for the listen server. I have been using “Event OnPostLogin” to initialize the inventory. In the GameMode event graph, I get the controlled pawn, cast it to MyCharacter and execute a custom event on the character blueprint.

GameMode event graph:
bd1ea961b84a9b4eb9f5bd8054e48b1dc0f3f00c.png

MyCharacter event graph:
f77d4be64085b83ed4f186f7b5302fe304d36974.png

The custom event “PostLoginOnChar” is set to “Run on owning Client” because I believe this is what I want… right? I only want the player who owns the pawn to have the GUI drawn for them. The “Is Locally Controlled” bool I feel like might be overkill, but it seems to work better with it.

So here’s where the problem starts. With this setup, the listen server never gets the GUI initialized. I have found the problem to be that when the “Event OnPostLogin” event executes for the listen server, the “Get Controlled Pawn” is invalid. I can only assume this is because the listen server executes events in a different order and the pawn isn’t created until later.

So… Question 1: How do I properly initialize the GUI for a listen server?

Now after here it gets messy… I’d like help with it because I’m pretty lost. In the tutorial, an “item” actor was created that the player could approach, press “E” on and it would move to the inventory. At the moment, only the listen server is able to interact with the objects. I am attempting to change this and failing horribly.

Item Actor blueprint
64b66beef19285b1e4c67c0a642ddf2821109012.png
6293152da98da7aaafabe36ad1db9f54945b4a3a.png

So… I’ve edited this so many times that I don’t even know what I’m doing anymore. This is the first time I’ve used an Event Dispatcher, normally I’ve just used interfaces for this kind of stuff. But I guess event dispatchers are better to use when possible so … here it is. So it should be pretty obvious what I’m trying to do. I want to have an event I can call when a player uses this item. But I’m very lost as to who would be executing this script and what is getting saved as the “Character Reference”

Character blueprint
8df24d57852131c67212c5fed5c9ffad0affaee8.png

I have this in the character blueprint event graph. Client presses “E” and has the server execute the Event Dispatcher “Call ActivateWorldItem”

So… “TEST” will only print for the listen server (who doesn’t have a GUI due to the first problem). The client has a GUI but I can’t seem to figure out the dispatcher setup.

Like I said, this is a mess… can someone help me sort it out?