Ok lets start with just having a Village BP. If you drag this out in the Editor it’ll procedurally place a bunch of meshes for buildings around. This makes it quick and easy to create “villages”. This is also not hard to do with ChildActorComponent or StaticMeshComponent.
The problem with this is that the Village Actor will act as one object. You can’t select one of these ChildActors inside the Editor and tweak it’s properties.
If you on the other hand drag a bunch of House BPs out in the world randomly, you can have a different Village BP look for these and use Attach Actor to Actor to attach them to the Village Actor (ie. itself). If done this way you can still select each House individually, but you can also move all of them with the Village Actor. This is what I want, and I think joessu too, but the size of the proverbial village may be too large to effectively drag each house out manually etc.
Seems weird to me that actors can’t be spawned in the construction script, even if added as children. I noticed that child actors can’t be selected in the hierarchy either, which is interesting.
Plugins? really? I think i would just modify the unreal source to allow spawning actors at construction time. Maybe inherit from a class that tags the actors that are created and deletes any actors of that type anytime construction is rerun.
Sure you can edit the engine source code. It would be better to make a plugin and then you could easily maintain it from engine version to version, and you could share it easily, plus you will most likely want to add more features.
We worked around it. Luckily our game is small enough to warrent manual placement of actors. Basically we have an array of actors that we set, and then the construction script loops through and positions them accordingly.
So to be clear, no we do not have a solution for this, but managed to not need it.
If you’re really really sure you want to spawn actors in a construction script (you’ll have to manage their lifetime yourself), you can put this helper function into a blueprint function library:
You can’t use this code for a BP Function, because BP doesnt allow you to set the world parameter, it just wont save the bp.
What you have to do instead, is to get a reference to an Object, from this object get the world. Replace UWorld* World with UObject InputObject, and World-> with InputObject->getWorld()->