Greetings,
I’ve been working on a number of custom UStructs for a given project. Originally, the purpose of the Structs were only exposition to BP so not having to dive into the constructor was alright. However, as the project has progressed, it is now part of the tasks to construct those custom UStructs inside of other classes.
Which brings me to the question: How does UStruct handle constructor/initializer declaration? I’ve been looking at what Google showed (Wiki [though it’s a tad hard to understand because of the code visualization errors in the wiki itself], AnswerHub, UE4 Forum, and others) and have tried those approaches with little success.
Update Progress
.h
//Where the Class is Struct FMakeTransformData
//Constructor
FMakeTransformData()
{ }
//Desired Constructor with all the variables
explicit FMakeTransformData(FVector Location, FRotator Rotation, FVector2D UpwardForwardOffset, bool SweepTrace, ETeleportType TeleportPhysics, bool SetRotation, bool StopIfSwept, EWorldLerpType LerpModel, float TransitionTime)
{ }
This ^ Compiles the Header class.
However, whenever trying to fill the structure inside a constructor file, it doesn’t work. I’ve added print Debug Messages to each constructor and Always, ALWAYS, the default (empty) constructor is called. How should I be declaring the constructor inside the CPP File?
This is currently how I’m calling it (and it compiles)
//In the CPP.
FMakeTransformData(EndVectorTracing[3] + CapsuleOffset, RotatorOutput, UpwardForwardOffset, SweepCollisionWithMovement, ETeleportType::TeleportPhysics, SetRotationWithMovement, false, EWorldLerpType::XYLineZLog, TransitionTime / 2)
If however, I save this in a variable (that is uproperty) and then print let’s say the Location (first item), it’s never actually saved.