Remove widget(s) from viewport for a specific character in split screen.

UE 4.13.
Blue prints.

What I want to do - Upon death a player is given a “ghost” so that the game doesn’t just end for them. They have limited functionality with the ghost and they don’t need certain parts of their UI anymore. For aestetic reasons we’re looking to remove parts of the UI, specific widgets when a player dies and takes control of their ghost. So I want to remove specific or if I have to all widgets from a persons specific viewport in split screen.

Attempts and layout - Currently the UI gets created in a playerHud blueprint class using create widget. Create Widget accepts a Player controller reference so it’s easy to create a UI specific to players but I am unable to find a similar method for removing them. Nothing I have found removes it for a specific character and instead removes it from all characters. Remove all widgets removes every widget for every single character in split screen there is no character reference. There is “Get all widgets of class” but that then removes it for all players in split screen when 1 dies.

My current plan was to call this in a “die” macro present in the character Blueprint. When a player dies a number of things happen. A ghost is spawned. they take over that ghost. Certain things turn off or on. So I was just going to add it to the execution of this macro.

You need to keep references of widgets, I strongly suggest keeping a reference object in the player controller. That way whenever you need to do any widget manipulation on it, you call the appropriate player controller’s widget reference.

For example, say you had a HP_Widget. Add a variable to your player controller of type HP_Widget reference. That way, after you create the variable for a player controller of that type, you can assign the created widget reference to that player controller. When something happens and you want to hide it only for that player, you then call the function on that player controllers reference.