GetPlayerController in EventInitializeComponent returns NULL

Hello! I have the Blueprinted component, which responses for detecting actors with this component attached in player HUD. My task is tracking some actors when them are spawning in scene (even if they are created in level statically) for displaying them in the UI list. I created blueprinted component, which adds itself to array in HUD class. I’m trying to get local player’s hud at component initialization time. I’m trying to use GetPlayerController with index 0, but it returns NULL and I can’t get assotiated HUD object. Is this normal behaviour or bug, and if it’s normal what is best way to do what I want? Here is screenshot of this componen’s event graph:

I found other confusing issue, that in my hud object begin play is called after first calls of EventTick, when I play with dedicated server.

Why you not call that using posses event. Because i think if you do this in the actor, it would not posses by the controller before posses is called(at keast, tgat’s what i know) jejejej

I whanted any actor with this component would notify player hud about itself creation. But in component initialization time (on placed in scene actors) nor player controller, nor hud isn’t created

Maybe it can works when you actor is spawned after begin play. Because i think when you try to call a player controller before that. It really not a good idea (see the initialization state of an object in unreal docs). My suggestion maybeI if you want to do a little cpp is iterate every actor that had this component in the player controller (just for actor that already placed in the world) for actor that spawned on the runtime. I think above implementation would works.

I think so, but it is really confusing, that player controller is not created at post initialization time of scene as I thought. And I had to do tricky thing in my HUD class cause issue in my comment above.

Hey, I think you had the same issue that I did. The problem is that you’re trying to call GetPlayerController when it has not yet been initialized by the engine. If you move that code to your game mode EventBeginPlay the GetPlayerController will return a valid value and your code will work.

Here is my post with the solution