Is there a proper way to guarantee the loading and creation order of the actors of a level?

I often run into the problem that actors that depend on each other, for example, a trigger, and the object it triggers, are created in such an order that the trigger doesn’t have the reference to the object that it should have.

I can fix it, looking for said object from the BeginPlay. But I see it more as a patch.
You can also make objects that depend on other objects spawn those objects themselves and configure them, but I find this tedious.

Is there any correct or recommended way to deal with these things?
By the way, this phenomenon makes things that work in PlayInEditor not work in StandaloneGame and vice versa. It’s funny, don’t be overconfident.

It’s usually a good idea to have some kind of class that handles the loading and unloading of things into the game, or initializing them in some way.
What I’ve done in past games is have the Game Mode or the Map Blueprint be responsible for actually creating/initializing everything.
Just spawn or initialize the items that are independent, and then spawn and initialize any items that are dependent.
If one class/object is completely dependent on a specific object then create an initialize function that gets called on spawn/begin play within the independent class that spawns or initializes the dependent class/object

1 Like