Spawning child blueprints

So this is a bit difficult for me to explain, but I will try my best to explain. Basically, I am trying to develop a building generator that can generate 2 different sized facades. The first facade includes a first floor that is 6M wide, and the above floors will add 3 2m wide windows. My Second facade sets up a 4M wide building with the floors above set to 2 2M windows. Eventually the floors above the first floor will be able to change window styes randomly. However, for now, I am just focusing on 1 window style.

My Theroy…
develop 2 child blueprints, 1 for the 6M facade and the second child for the 4M facade. The parent blueprint will control the number of facades to generate, randomly pick between the 2 sized facades, and add the corner and side walls at the start and end points. An example would be something like…
6M 3 floors, 4M 2 floors, 6M 5 floors, 6M 5 floors etc.

However, there is just one problem. I have noticed that I can only spawn child blueprints using a custom event. I do not want to do it this way, because I would then have to keep updating the event every time I change the number of facades. I am also hesitant to merge everything into one blueprint, because the settings of each facade is a bit different. So does anyone have some suggestions? I will eventually have a diagram within the next day or so.

This is an example in Blender…

You can spawn child blueprints from the construction - if you’re using Blueprint, just put the Spawn nodes into a function and call that function from the construction event. If you’re using c++ you can add SpawnParams - there’s one called something like bSpawnFromConstruction or something like that.

This is really odd, because the spawn actor class fails. Here is my function. The function calls, but when the script hits the spawn actor node, nothing happens.

Is MasterCurrentLocation world space or local? the spawn will be in world space - you might find them somewhere completely different to where you expect.

I did a debug, and I got an error…
Blueprint Runtime Error: “Accessed None trying to read property CallFunc_FinishSpawningActor_ReturnValue”. Blueprint: MasterBuildingGen Function: Spawn 6Meter Graph: Spawn6Meter Node: Set L_TileSize

… also, the MasterBuildingGenerator root is at 0, 0, 0 and MasterCurrentLocation starts at 0, 0, 0. So I do not think that is the problem

…however, the class spawns when I place this in a blutility event

yeah, I just tried and it didn’t work for me - you can add a “call in editor” function to call your constructor, but it’s not the best solution…
I’m doing it from c++ but it’s a bit different - you may be able to create a simple c++ function to do it, or base your building blueprint on a c++ class that does it from it’s constructor…

so I found a video, discussing about spawning actors, by Mathew Wadstein. He explains, by default, blueprints only list spawn actor from class under the game category, which means it is only a runtime node. To make it work in the editor, you must enable the “Editor Utility Widget.” So I am wondering why Unreal disables it by default? :thinking: Is this not the best solution either?

I just thought of something. Each time you change something, such as moving the facades to a different location, spawning is not the best option, because the spawn actor will add on additional actors, even though the “numFacades” variable is a fixed number. So in other words, if you started with 3 facades, and moved the blueprint somewhere else, you would then end up with 6 facades. So technically, I would need to to call a custom event that spawns only new actors when the number of facades is larger than the previous amount. In addition, I would need a custom event that will destroy the number of actors if the number of facades is less than the previous amount. So this does not sound ideal.
So, I am back to square 1, and I need a way to build a blueprint that can change the number facades dynamically. I am wondering if it would be better to focus on making 1 Building at a time, and then use a L-System to fill in the city blocks. :thinking:

Perhaps you could add StaticMeshComponents to your Blueprint Actor rather than spawn actors directly into the level? Construction would always be from a clean slate…

Are you referring to using one Blueprint? I was thinking of doing something like that, but focus on one facade at a time and turn them into prefabs.
I also did find a procedural building generator on the market place. It is called PBG, but I think it is a bit complicated. It certainly has more features then I need, and I don’t know if I can set it to have random store fronts. However, I will give it a try. Also, if anyone else has some suggestions, I would love to hear from you. Thanks in advanced.

I’ll be releasing on the marketplace what I’m working on at the moment soon - which takes “prefabs” or just actors in the level, makes them randomizable and converts them to Instance Static Meshes amount other things - sounds like it could work very well for what you’re doing - keep an eye out…