[Code Request] To fix construction script for procedural usage.

I’ve been working on some procedural generation ( on Blueprint ) script since UE4’s release.

So far, everything is good until I hit a major stumbling block. I am writing this as a request
for anybody who is good with codes to help me adjust some limitation, this is definitely possible given the
full source, although I don’t know how complex it is. I’ve already reported this problem as a bug in Answerhub,
but the staff seems to tell me it is an expected behavior.

Here’s the problem;

Construction script runs when actor is spawned. However, if you use any script that detects surrounding object DURING

construction script, you’re going
to run into issues with the order object placement, because it can only detect object that ALREADY has been place.

If you see the Epic’s Blueprint Example, you will see a Procedural Grass that detects floor normal. This would break as well
in real usage because if your grass is generated BEFORE The ground is place ( during game ) , then the grass blueprint will detect


Possible Solution:
The solution is pretty straightforward. Delay construction script until everything is spawned. For the case of blueprint, at least
spawn the root first. Or have a checkbox for components to say if this needs to be spawned PRE-Construction Script.

This is the link to the proper explanation in Answerhub

The answer-hub link you posted is broken.

I don’t get your problem. If you create components in object’s constructor, then they’re already placed when construction script is run.

What is more, you can always set proper positions later(For example when loading ended).

I don’t think simply delaying the construction script is very good since you won’t be able to see what the result will look like beforehand. This could also be an issue with static lighting.

Sounds more like you just want to run the construction script again (manually) when something (close) is updated, deleting everything that was generated last time (not sure whether that happens automatically?).

The other solution I see would be to simply not have the generation stuff in the construction script and instead do it when the game begins.

Sorry, the link was indeed broken. I copied this from google cache when I noticed the thread was missing ( I believe apparently caused by some server issues as announced by Epic )

I don’t think delaying construction script is the right word I should be using. Changing the order at which is happen would be more accurate to say; spawn root and all components THEN run the script.

Generating stuff on EventGraph would not be ideal. I found out (from Epic response ) that they have a special code for construction script generated components to have their lighmap persists over
even if the models were generated during runtime.This would only work if it’s done on construction script. If we generate the object on the normal EventGraph, this would not work.
I initially thought that whatever that gets generated over construction script only gets generated during game load, which naturally would mean
they do not have static lighting. However this is not true.

Setting proper position is fine. But in my case, I’m generating the meshes based on whether or not surrounding meshes exist ( based on cast result ).

To give you guys a clear idea of what I’m doing. this is the link to my WIP procedural work. The automated window system is randomly broken in-game due to the fact of this problem.

We have seen some issues like this where one BP CS needs to run after another, so it can use its result. In those cases, we’ve used calling between actors in the construction script e.g. put the functional chunks of the CS in their own functions, which can be called from the other BP.

Hi JamesG. Thank you for your presence in this thread.

Let me reclarify, so you’re suggesting we put some of the CS’s functions in the normal eventgraph functions and then get other BP to call it?

Either in the event graph or in a function, and yes - the other BP calls that to ensure its done first.

I’m having a similar issue in a map with static elements that are relocating themselves from time to time on map load from the construction script re-running. Did you ever find a cleaner method than just throwing it in the event graph?

Yeah, this is still a super annoying thing. I can turn off “run constructionscript on drag”, all I want is a “run constructionscript only when I tell you to and keep the result and run at no other time ever” option.