Creating widgets in the PlayerController, and widget Ownership

Hi, in UE4.24 the create widget node has an Owning Player input pin. Do I need to set this to the player controller? or does it default to Self and it is a bug not showing that default?

It doesn’t default to self, you need to plug in the correct player controller depending on the context you’re calling it from.

If you don’t pass a value (or pass a null value) to player controller though, It will try to create a widget anyway.

If you’re interested:
1 - if you pass player controller - it will use it
2- If not, it will try to get the game instance from the world, and use the GameInstance.GetFirstGamePlayer()
3 - If game instance isn’t available, it will try to use World.GetFirstLocalPlayerFromController()

It also seems like even if after all that the LocalPlayer is still null, the widget will still be created.

So, in a listenserver, GameInstance.GetFirstGamePlayer() will be the listen server client, and for normal clients GameInstance.GetFirstGamePlayer() will be the player. Is that correct? and if used in the player controller, wont the player controller be the GetPlayerControler node output with an index of 0.

Or is all of that not reliable and so it works most times but can fail so I would be best to put in the PC each time a create a widget?

I haven’t played around with multiplayer enough to answer those questions, so either someone else can fill in the gaps or you can try to read in the documentations.

But personally I’d always connect an input pin to the PC when creating a widget; I’d much rather decide who that widgets belong to on my own rather than rely on defaults, specially since it’s not specified (meaning it’s not guaranteed and can change in future versions without even telling you)

Interesting, I would rather have defaults that can be overridden, :slight_smile: