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.