RedChiken
(RedChiken)
February 8, 2019, 4:56pm
1
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.
BenVlodgi
(BenVlodgi)
February 8, 2019, 6:05pm
2
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);
RedChiken
(RedChiken)
February 9, 2019, 5:42am
3
Thanks for help.
I’m using C++ and don’t understand about modifying the spawn flags.
what 's that?
BenVlodgi
(BenVlodgi)
February 9, 2019, 5:23pm
4
Updated answer with C++ info.
RedChiken
(RedChiken)
February 12, 2019, 10:55am
5
thanks for reply. I find another solution. It doesn’t matter that spawn actor in BeginPlay(). I appreciate with this answer.