Download

Spawning actors after spawning GameMode

Hello community.
What I want :

Spawn sigleton instance of actor which have only array and add every actor on scene to this array.
I spawn sigleton instance to scene in GameMode OnConstruction (which I think is one of last actions ).
During spawning these actors I want to add their reference to my sigleton array (this is handled in BeginPlay of each actor).

My problem is that GameMode OnConstruction is called after BeginPlay in my actors.

Is there any way how to ensure spawning order ?
What I need to do when I need spawn one actor before any other actor ?

I appreciate any help or suggestion.

Thanks.

I don’t think there’s a better order to do it the way you’re aiming to, but when GameMode’s OnConstruction is run, you could maybe do a search for your actors using TActorIterator<AActor>?

Thank you. I used TActorIterator and it’s works fine. I was little concern about using iterators but it looks like they are very fast.