Spawning Blueprints via another Blueprint Constructors Script

Hi all,

This evening I set to do something I expected to be very simple. However, after a couple of hours of digging I’ve no idea if this is even possible.

The idea is pretty straight forward:

  1. Create a Blueprint called CaveSection - This blueprint consists of 2 items, a static mesh and an vector3d array called joints.
  2. Create Child Blueprints of this class, where I setup lighting and other items within the cave section and I set the joint locations.
  3. Create a Cave Blueprint - This has 2 variables also, Int NumberofSections and Array of references to the blueprints (At the moment this is set as an array of Class CaveSection)
  4. Cave Blueprint Constructor script randomly pics a CaveSection and spawns it at a free joint section of a previous section. (Logic here will be much more involved but I’m keeping it simple here)

The issue Is I have no idea how to make the Cave Blueprint Construction script execute that logic.

Any thoughts?

Thanks

Swifty

p.s. Done loads of googling a forum searchs and not come up with anything particularly useful (maybe im googling the wrong question)

Hi Sw1fty,

The node you are specifically looking for is “Spawn Actor of Class”, with the class type being your other blueprint. This will spawn copies of your other blueprint based on the parameters you give it, so if you set the location, rotation, scale, etc within your Cave Blueprint and spawn these through for or foreachloops.

Thanks for the responce .

I guess there’s a bug then, because 4.7 doesn’t allow “Spawn Actor of Class” in a construction script.

As a work around I’ve decided to manual setup the cave enterance in the Cave blueprint and then dynamically create a cave. This is going to be a cool little system.

Thanks agian

Hello guys, so if I use ‘Block’ BPs event graph and spawn another actor, is the new actor a child of ‘Block’? And if so, what does this mean for how things will work within the BP and new actor?

Hi,

[]
I guess there’s a bug then, because 4.7 doesn’t allow “Spawn Actor of Class” in a construction script.
[/]

Im using “Add Child Component” (see link below).
That seems to work very well in terms of blueprint creation (FassadeColumn), but fails to work for setting its variables when spawned by a FassadeRow BP…

@
Im doing basically the same thing. Creating Blueprints from Blueprints.
But I cant seem to be able to access/set set variables of those child components…
Maybe you can give me a quick pointer??

Problem description: https://forums.unrealengine.com/showthread.php?68646-Still-a-problem-with-acessing-a-child-actor-component-s-variables

Thanks,
Klaus

The way I do it is to have a custom event within the blueprint that essentially replicates what you would have on the child blueprints construction script and then simply spawn the child actor and cast to your “blueprintSetup” event on it and feed across any variables that you want.

[]
The way I do it is to have a custom event within the blueprint
[/]

But that would only fire during play, or not?
So during design-time, in the viewports, you would not see any changes, unless you hit “play”…
Or am I wrong?

I use blutility functionality when I want it to appear in the viewport. Only downside to this method is that when you move the actor around then it resets to it’s original construction script state. I was hoping to find a way to stop the constuction re-running every time you move an object, which is why I originally turned to a blutility, so currently it works but isn’t ideal

[]
I use blutility functionality when I want it to appear in the viewport
[/]

Ah ok. I try to cretae a fully self contained solution without the needs for level scripts, runtime events or editor extensions (Bluetilities).
I try to design my assets as if they were for the dumbest level designer ever :rolleyes:

Hi so I got the Cave generator working at run time with EventBeginPlay.
However, I have been unable to get it working in the editor (I’d like it in the editor to make tweaks in build lightmaps)

When I run a custom event in editor that executes the BuildCave Function the collision detection does not seem to fire.

Do collision events only work at run time? Is there anyway to force them to work in the editor for a short while?

Here is the main function “TrySpawnSection”

Thanks all

I came upon this post when I was trying to get spawning working in my own construction script.

Best way to get around this is to just use Spawn Actor inside a custom method that you toggle Run In Editor on for.

What happens is, there’ll be a button for your method popping up in your actor details panel in the map window, when you’ve selected your main blueprint that does all the generation. Just click that button and it’ll spawn whatever you want, right there in the editor.

Now just make sure you add all spawned actors to an array that you manage as they get spawned, and the next time your method runs, first destroy all previously spawned actors before spawning more.

Also use AttachActorToActor, to attach all the spawned actors to whichever actor does the spawning. That’s what I did at least, so I can drag my spawning actor and all attached actors just drag with it.

2 Likes