Have problem with spawn actor

I tried to make trigger that close the door(another actor) when it broken.

So I tried to attach trigger actor to door actor.

But when i add SpawnActor code in door actor’s constructor, project is crashed.

I search so much, but cannot find without SpawnActor.

I want to find solution about SpawnActor, or attach actor to actor.

You cannot spawn an actor in construct unless you use C++ and modify the spawn flags.

In Blueprints, you will want to use a ChildActorComponent, when you set the ChildActorClass, it will spawn a new actor as a child, and you can get its reference.

For C++ I suggest either using the ChildActorComponent, or using it as a reference to see how they handle spawning and construction deferring.

Here’s how that component handles spawning actors in construct.

Below is a summary, though some of the other code may be important.

FActorSpawnParameters Params;
Params.bAllowDuringConstructionScript = true;
ChildActor = World->SpawnActor(ChildActorClass, &Location, &Rotation, Params);

Thanks for help.

I’m using C++ and don’t understand about modifying the spawn flags.

what 's that?

Updated answer with C++ info.

thanks for reply. I find another solution. It doesn’t matter that spawn actor in BeginPlay(). I appreciate with this answer.