How is usually initializing / loading actors done?


on the loading screen, how is initializing / loading of the actors done? I mean, some actors need to fill arrays or something, make calculations. For example I have some actors that need to create a neighbors-graph for finding neighbors later in the game.
Is there a usual way to do things like this? My idea is to implement an interface “LoadableActor” with a “Initialize()”-function. In the loading screen then after the level is loaded but before BeginPlay() is called call FindAllActorsWithInterface (don’t know the exact name now) and call the function on all actors in the level which implement the interface. Is there a better way?

Thank you,


You can just do this sort of the in the BeginPlay event of each actor. The only thing you have to watch for is the other actors not existing yet. This is only a problem if you using spawning. If all the actors have already been placed in the level, don’t worry.

So, begin play, possibly a delay while you wait for other actors, then do the initialize.

This could be this type of game where you’re experiencing a huge lag right after the loading screen has been closed :smiley: As I understand it, when BeginPlay() on the actors is being called, already all actors in the level are existing. There is another event accessible per C++, StartPlay(), where all actors are already existing, but BeginPlay() has not been called yet on any actor. In this event I want to call my Initialize()-function on all actors which implement the interface. Right after that I can close the loading screen. This wouldn’t cause this huge lag after closing the loading screen.

If it’s going to cause a huge lag, it will do so whenever or whereever you call it from.

If you’re streaming, you have to wait until other actors are available before starting.

But how is then loading usually done? Complex calculations will always cause a lag if they’re made in the same thread as the graphics. But the graphics can’t be done before these calculations have been done. Is there usually another thread used for those calculations so that no lags can happen in the loading screen?

When you’re developing a game, there’s no standard way of doing things.

The best thing you could do is figure out a way of staggering the intialization so it doesn’t happen all at once.