Execute BeginPlay() for the level before any actors

There is some setup code I want to run for every level, ex. adding the HUD to the screen, so that actors inside each level can say change stuff in the HUD. Currently I’m using a class derived from ALevelScriptActor that overrides BeginPlay() to do the setup code. However, an Actor inside the level calls BeginPlay() before the level’s function can execute. How do I change the order, or is there another function/place I should be placing that per-level setup code?

Edit: I need to call GetWorld() in the setup code so I can’t do this in the construction script.

you can try using the construction script, that gets run before begin play. Or put delays in the beggining of the begin plays you want to wait

Forgot to put it in the question but I need to call GetWorld() during setup so I can’t use the construction script. I also don’t want to use delays due to timing uncertainties, but thanks if I can’t find anything else I’ll try it.

There’s always PostInitializeComponents(). You can override that. It runs before BeginPlay(). Not positive it runs before BeginPlay() for all actors but it’s worth a try.

If it works, just be sure to call Super:PostInitializeComponents() before you do your stuff.