Download

UI in editor testing but not in packaged game

I have an interesting problem that I haven’t the faintest idea on what causes it. In editor testing - my in-game UI works fine (crosshairs, ammo count, etc…); however, in a packaged build (debug, dev, or shipping) it does not. The UI simply isn’t there. I checked the logs and saw nothing about not being able to create the UI or casting failing or anything of the sort. Keep in mind, this is a multiplayer game.

I am having the player controller create the widget, then saving it as a variable and passing it to the pawn that it takes over in begin play. I then wait for a custom event from the pawn called On Ready.

In the pawn’s begin play - I go through a has authority check and if it is server, spawn the starting weapon, equip it, then send out the On Ready event. If is a client - I just send the On Ready event.

When this happens, the PC then sets up the UI (configuring the ammo count for example) and then adds it to the viewport. This process works as expected and as desired in editor, but not in any packaged build.

Last night - I was trying various things and what ended up working in a packaged build was if I add the widget to the viewport directly in the PC (at the end of the Begin Play event), without waiting for the On Ready event. Because of this - it leads me to believe that maybe, something is going on with the networking side that is causing the PC to fail to respond to the On Ready event. And inside of this response is when I add it to the viewport. I tested this theory again with some lovely print statements, and indeed - the response was never firing off.

Does anyone have an idea of what is happening? Is it a race condition? It would make sense, and I thought about that when building it out, but it even happens when you are the only one there and you’re the listen server.

(please note - I don’t particularly like the way I’m doing this, I just haven’t worked out a way to do another way, so if you have a better approach, feel free to correct me on this as well)