[Request] Spawning actors in Blueprint Construction Script.

I know there is ChildActor Component.
But for what I need it, it is severely limited, as I need to set blueprint to spawn, in advance and can’t change it later.

What I require is ability to expose Array with classes of blueprints to spawn. Then user can set any numbers of blueprints, to spawn, AFTER the master blueprint has been placed on level.

I definitely agree. Why can we spawn AI in CS but not spawn from class? It makes perfect sense from a level-building perspective to randomly populate a scene beforehand so it isn’t different every time.

A workaround I’ve found though is to spawn your actors at runtime, select them all in the scene outliner and copy them. Then stop the game and paste your copied actors. It’s a workaround, but it’s an option!

Can you provide some more details on what you mean by spawn AI in Construction Script?

Spawning Actors directly in the construction script would result in massive duplication of the generated Actors as the construction script gets re-run a lot of times unless we did a substantial amount of work to associate the spawned actors back to their parent … kind of like what ChildActorComponent does. And before you ask why we don’t just make Spawn Actor do the ChildActorComponent thing automatically, it isn’t really all that possible (and certainly isn’t good API design) to make SpawnActor behave differently in construction script vs. event graph.

ChildActorComponent is absolutely the right way to do this and we do plan on making it parameterizable both for which class and likely the same expose on spawn parameters will also be available. Unfortunately, there are some other things that are currently taking priority (cyclic dependencies in blueprints is probably the most directly involved) so I can’t give you a timeline, but it is something we plan on doing.

Thanks, it is exactly what I have in mind (;.

I’m talking about this, specifically:

Untitled-1.png

Disclaimer: I have no idea what this node does as I have yet to delve into AI in UE.

Can you point me to some documentation on how Add ChildActorComponent works? I can’t seem to find any or figure it out on my own.

Thanks for pointing that out, that is definitely a bug. I’ve filed a ticket on that to the appropriate team.

I’m not sure there is much in the way of explicit documentation. ChildActorComponent is a SceneComponent that can be added via the Components panel of the Blueprint editor or via a Add Component node in a Construction or Event Graph. It manages the lifetime of an Actor of a given class that is spawned in the world and attached to the component, so as the component’s position changes so does the Actor’s.

Thank you for explaining! I think I understand what it does, but I’m not clear on its use. Could this be used to spawn multiple instances of the same actor randomly around the landscape?