How to force construction script to execute?

I created a blueprint A that references a blueprint B.
In A construction script I change some parameters of B, but those changes are not visible because it don’t run construction script in B. I can only see those changes if I change any parameter of B manually to trigger the construction script.

Is there a way to construction script of A trigger construction script in B?

Thanks

Hi Jandex,

The construction script only fires when the object is initially created, so to cause the construction script of B to fire you will have to destroy and recreate the object or in some way move the object (which actually destroys and recreates the object at a new location).

Or you could define a new function in Blueprint B. Let this function do what the construction script does. Then you can call this from A. I had to do this very recently to create a solar system.

2 Likes

Hi, Adams answer isn’t strictly true …
construction scripts also run when you compile and save a blueprint, even if you haven’t changed anything in the BP :wink: (technically it may be destroying and recreating the nodes?) … anyway…

In my case I have nodes that are all of the same class (BP) that need to know which other nodes of the same class they overlap with in the Editor. The obvious problem is that the first one I place in the scene overlaps with no others as there is nothing to overlap with. If I place the second one in the scene, overlapping with the first, its construction script spots the overlap … but the first node will need to rerun its construction script again to spot the overlap. So the simple answer for me is place all the nodes in the scene that I want and then compile and save the BP.
Hope this helps, I realise that it’s not automatic but for my use case it’s perfect.
rOb

You can create a node for AActor->RerunConstructionScripts(); in a C++ BP library, to manually rerun any Actor’s construction script.

2 Likes

can you point me to some doc that explains how to do that please? i currently have construction script generated spline with random offset points, but it will only update and generate if i move it in the editor, and i need it to update everytime the level is played (for procedural generation)

@mindfane, sory for this archeological reply, maybe you can point me in the right direction.

I was trying to do what you say, but the function will not be executed as expected. I ticked “Call in Editor” withing the function in B but the result is not visible in B while the function is clearly executed wien I change anything in A. Let me know if you think of something

best regards.

my only solution for this was to have anothet actot destroy and rebuild the actor with the construction script (for procedurally generated actors) … so the actor with the construction script has a struct with all of its settings, and thr other actot takes those settings, destroys the “construction script” actor and spawns a new 1 with those settings that were in the struct