How to handle the Begin Play events for actors added in the editor?

Hi, I have a few actor blueprints that I have added to the level in the editor. All of them have executable code running as part of Event Begin Play. And in one case, the actor is referencing another one of these actors. It is running smoothly as this point, but I don’t think what I’m doing is safe practice.

What if the referenced actor [Let’s call it Actor B] has not finished initializing in time? So should I fire off that begin play functionality as part of a custom event that is called when the first actor [Actor A] goes through it’s begin play event to the completion?

You could put a half second delay in.

That would make sure they all exist before anything happens.

Narg

Yes I suppose that should work in some cases, but it still doesn’t guarantee that the other actors have finished storing a reference that I can use. The begin play code would still start running for all actors at the same time.

Do you know if there’s any standard workflow that’s used in the industry to handle stuff like this?

All depends on how you are referencing them.

Narg

I got the answer from the Unreal forums. It seems it’s better to spawn them as part of another script like level blueprint or game mode rather than just putting them in the editor. Here’s the link to the forum post:

https://forums.unrealengine.com/showthread.php?69674-How-to-handle-the-Begin-Play-events-for-actors-added-in-the-editor&p=289642#post289642

the half second delay suggestion is poison. can someone remove it?

its terrible leaving it here in a place that’s meant for answers…