Implementing a native code Construction Script

Within Blueprint, Construction Script is an event graph that runs any time a property is changed on the object it is attached to—whether from being dragged in the editor viewport or changed via direct entry in a Details panel.

Construction scripts allow the object in question to 'rebuild' itself based on its new location, for instance, or to change the components it contains based on user-selected options.

When coding in C++ with Unreal Engine, the equivalent concept is the OnConstruction function.

How to do it…

  1. Create a new Actor called AOnConstructionActor based on StaticMeshActor.
  2. Add the following UPROPERTY to the class:
    UPROPERTY(EditAnywhere)
    bool ShowStaticMesh;
  3. Add the following function definition: ...

Get Unreal Engine 4 Scripting with C++ Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.