Does the constructor script of placed actors execute in game?

For the actors you put in the level in the editor, does the constructor script executes when the level is loaded in the packaged game? I suppose it shouldn’t run but I want to be sure.

I’ve put a printstring in the construction script, it prints when I load the level in the editor but also when i play “Standalon Game” from the editor.

What happens in the packaged game? (printstring don’t work obviously so I don’t know is it executed or not)

1 Like

No, they don’t. The construction (not constructor, that’s a different thing) script is editor-only. With ordinary Blueprints (no custom C++ base class), the first thing that gets executed is BeginPlay().

2 Likes

pretty sure the blueprint construction script gets executed in game

2 Likes

Just to clarify, I’m asking about blueprints added to the level in the editor, like props, architecture etc. not those spawned in game.

1 Like

edit: this post is nonsense, ignore it [HR][/HR]I was confused about this for a long time.

The Construction Script for objects placed manually in the level does get executed; you will not see a Print String fire, though.

Put an object in the level, set a variable in its construction script and read it OnBeginPlay. It will be set.

1 Like

It’s not a proof. Maybe the value of the variable was serialized and saved with the level?

2 Likes

Sorry, It’s a pretty big thread, where is the answer in there?

1 Like

Hm, you’re right. I just made the var into a random value and it does not change, indeed.

2 Likes

Objects pre-placed in a level have their construction scripts ran at cook/“package” time. They are solidified in the level during that process.

Dynamically spawned objects however will run their constructions scripts as they’re created. Events like BeginPlay, where some setup/initialization script can be placed will also be executed at runtime

Taken from: Running BP construction scripts at Package Time - World Creation - Unreal Engine Forums

5 Likes

Thank you!

1 Like

Interesting. I stand corrected. Maybe that’s something that changed, because I’m reasonably certain that when I started learning UE4 (which was some time ago), they really hammered the point that construction scripts don’t get executed in.

1 Like