In this lesson, you will learn how to use the Construction Script to procedurally configure your Actors the moment they are placed or moved within the Level Editor.
What is the Construction Script?
Up until now, you have likely set up your Actors by manually dragging components into the Components panel. However, this is static; if you want to change the appearance of 50 fence posts simultaneously, doing it one by one is inefficient. The Construction Script is a specialized event that runs automatically every time you place an instance of an Actor in your level or modify its properties in the Details panel.
Think of it as a "setup recipe" that the Engine executes for you behind the scenes while you are still working in the editor.
Practical Application
Suppose you have a light fixture Actor. Instead of manually turning the light color to blue for every single instance, you can use the Construction Script to set the light color based on a variable.
In your Blueprint, open the Construction Script graph. You can drag your LightComponent into the graph and connect it to a Set Light Color node. If you create a Variable (e.g., LightColor), set it to "Instance Editable" (by clicking the "eye" icon next to it), and pass that into the Set Light Color node, the magic happens:
- You place the Actor in your level.
- The Construction Script runs.
- You change the
LightColorvariable in the Details panel. - The Construction Script re-runs instantly, updating the look of the Actor in your viewport without you ever pressing "Play."
Why Use It?
The Construction Script bridges the gap between static level design and dynamic programming. Because it runs at both Editor-time and Runtime (when an Actor is spawned), it ensures your object is always in the correct state, regardless of whether you are arranging your level or the game is actively running. It turns your Actors into flexible, modular tools rather than rigid objects.
Key Takeaway: The Construction Script is your procedural automation tool, allowing you to dynamically update an Actor's visual properties and component arrangements the moment its settings change in the editor.