Access level actors from Player's HUD
I want my player to have an HUD (UMG Widget) with some buttons that control the visibility of some objects or print the position of others.
My approach is to:
There is only one problem: since for various reasons it takes a while to spawn the player pawn, the begin play of the level is executed first, meaning that when it tries to get the player pawn and cast it and assign references, it fails the cast , because the player pawn has yet to execute it's begin play. If I put a delay of like 5-10 secs, everything works perfectly because in the meanwhile the pawn gets created.
Is there any better approach? I just need to access level actors from the Player Pawn.
edit: some screenshot
Try to move Level blueprint (step 3) logic to the Player Pawn.
This means that you have to "set the variables with references to the level objects" in the pawn which might further delay the pawn spawning but it should work. (the main performance hit is on the "getting" of the actors)
Now if the actor list and the UI is not dependent on the spawned Pawn you might use another object's begin play to do this. The widget creation needs a valid player controller regardless of weather it has a pawn or not so you can move the variables in there. (I think it is begin play is done after the level so you should have access to the actors - If not you can always use onPosses)
answered Aug 29 '18 at 09:59 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here