Initialization order

I have a structure of level building blocks that are all connected to each other, I wrote the code for establishing the connection in the BeginPlay() method because I need the bounds of every object, which apparently are not available in the constructor.
I also have a custom actor that need the blocks to be connected before his own BeginPlay() method is called. Is there any way to set the order in which BeginPlay() is called or some workaround to solve this problem? Because it looks like the initialization order is not determined and when my actor calls the BeginPlay() method first it basically can’t do anything.

Perhaps someone else can provide the direct approach via PostInit processing, but I wasn’t successful with that, the timing was off with my blueprint derived classes. I chose a workaround.

This is to change to using a deferred spawn and do intermediate processing of various sorts. The deferred spawn will create the components and stop at that point, to allow you to do initialization prior to completing the spawn with object->FinishSpawning(FTransform());.

I create a "PreProcessing() function I put into classes that I am going to split up this way for pre-BeginPlay() initialization. I call the deferred spawn, then call my Preprocessing on the pointer returned, then call the FinishSpawn().

The deferred spawn is accomplished by spawning as normal but using true for the last parameter:

    FActorSpawnParameters SpawnInfo;
    SpawnInfo.bNoCollisionFail = bNoCollisionFail;
    SpawnInfo.Owner = Owner;
    SpawnInfo.Instigator = Instigator;
    SpawnInfo.bDeferConstruction = true;

Completion of the spawn is accomplished with something like:


Then in-between those, do your initialization either from without via the pointer to the new class (called PointerReturnedFromSpawn in my example), or by calling a Pre-processing function you create within the class as I do.

I meant to add this. It is where I got the above, but also may help you find another approach: