What is the proper way to make sure BP Events fire in the right order in MP games?

I have been having problems when working on my multiplayer project, in that sometimes, my initialization on characters where I set up vital pointers to various objects during BeginPlay of an actor fail because those objects haven’t loaded yet on the client and so on. Then all sorts of nasty errors appear, both those that spam the log and those that are almost impossible to detect.

The only solution (which seems to work about 50% of the time) that I know of, is to put a long delay node of like 5 seconds after BeginPlay before the initialization occurs. Then I can be pretty sure that the PlayerController, PlayerState, GameState etc. has been spawned. And after initialization is done, I make a FullyInitialized bool true. And no ticking or movement is allowed before FullyInitialized is true.

It feels like a hack and that there should be some easier way to check if everything is ready. Some event like SafeBeginPlay or something, which fires in a Character when the owners PlayerController, AnimBlueprint, PlayerState and the GameState is ready. Or likewise, if it was used on the PlayerController, it would wait until the controlled Pawn also was ready, then fire.

So is there any better way to solve this than to introduce a delay in BeginPlay? Thanks.

This isn’t a 100% clean solution, but you could implement an interface on your erroring object with your own SafeBeginPlay Event inside of it. You could then call that once your playerController is made and initialised.

Execution order is as follows (I believe): GameState → PlayerState → GameMode → PlayerController

Once again, not 100% clean, but I’m pretty sure it will get rid of most of your problems.