How to Override the UE5 Construction Script in C++
Quick overview on how to recreate the construction srcipt in C++ in an Unreal class.

Game Engine
Unreal Engine 5.5.3
IDE
Rider 2024.3.5
Project Name
MyProject
OS
macOS Sequoia 15.3
When working on a Data Table example post I wanted learn how to use the Construction Script in C++. Luckily, using the Construction Script in C++ was trivial.
For example, create a new Unreal actor class and then override the OnConstruction method with virtual void OnConstruction(const FTransform& Transform) override
.
...
class MYPROJECT_API AMyActor : public AActor
{
GENERATED_BODY()
public:
...
virtual void OnConstruction(const FTransform& Transform) override;
Now we can use it in our .cpp
file.
...
void AMyActor::OnConstruction(const FTransform& Transform)
{
Super::OnConstruction(Transform);
// Your code here ...
}
And that's pretty much it, OnConstruction
will now in the editor each time a property is changed for the MyActor
class.

Harrison McGuire