I’m trying to add a blueprint actor from the construction script of a parent and change values that would affect the construction of the child blueprint.
Is it possible for one construction script to communicate with another?
I’m trying to add a blueprint actor from the construction script of a parent and change values that would affect the construction of the child blueprint.
Is it possible for one construction script to communicate with another?
You can create variables of what you want to change, then set all of them to “Editable” and “Expose on Spawn” in the variable details.
This will add additional pins to the “Spawn Actor by Class” of those variables and you can use them in the construction script already.
If you want to use a “Self” reference you will have use “Event Begin Play” since the actor doesn’t exist during the construction script and will give you an empty reference if you use self.
I hope this helps.
Cheers
Unfortunately that won’t work for me. It does indeed expose the variable when the blueprint is spawned, but I can’t spawn a blueprint from the construction graph. I can add a child component but I can’t seem to reference it.
What kind of BP do you use?
In a basic actor BP you can spawn other actors from the construction script.
You can set variables like I explained. You can spawn something and save a reference to it in the parent BP…
I don’t quite get what you have an issue with…
You can only spawn static meshes, not all other actors.
Ah right. That was Spawn AI from class… sorry for that.
But it does work with “Event begin play” in the Event Graph.
As I said it’s pretty much the same. I mean does it really make a difference for you if you spawn all of them before that actor exists or after keeping in mind that both happens during the same frame?
Making some procedural stuff so I need to do it in the constructor.
Is it a tool for level designer?
Because otherwise there really isn’t any difference.You won’t be able to debug it without simulating but as far as the actual functionality ingame goes there isn’t one.
I mean it’s the only way to get a reference to the original actor if you really need one.
I had a similar issue. I need this functionality, for use in the RoadGenerator blueprint from the tutorial by epic.
What I need is to spawn blueprint actors from class along spline points, this is needed for more logic of the track itself, I want to add CarWaypoints along the track, and to track the position of the player.
I tried to add this code Can't Spawn Actors in Construction, so now what? - Blueprint - Epic Developer Community Forums but it wont bring the effect I want, and breaks the roadgenerator bp itself too.
The answer can be seen here:
Add this function to a BP Function library, and please read my comment in the answer section (the code isnt 100% functional when you dont change it a bit):
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()->