I’m creating a plugin for Unreal with a BlueprintFunctionLibrary. Since I don’t want to have functions that are too long, I want to delegate the different tasks to different classes according to OOD.
I’m rather new to C++, so this might be a stupid question.
So I’ve created this class which holds some positions with methods to get them :
I’ve created the class with Unreals ClassWizard and made it private. However I want the constructor to be public so i can create an instance of it inside my BPFunction.
UCLASS()
class UTracePosition : public UObject
{
GENERATED_UCLASS_BODY()
FVector start;
FVector end;
FVector Forward;
USceneComponent* arrow = nullptr;
public:
UTracePosition::UTracePosition(USceneComponent* Arrow);
FVector getForwardVector()
{
return Forward;
}
FVector getStart()
{
return start;
}
FVector getEnd() {
return end;
}
};
And here’s the .cpp
#include "TracePosition.h"
UTracePosition::UTracePosition(USceneComponent* Arrow)
{
arrow = Arrow;
start = arrow->GetComponentTransform().GetLocation();
end = arrow->GetComponentTransform().GetLocation();
start.Z += 20.0f;
end.Z -= 20.0f;
Forward = arrow->GetForwardVector();
}
When I try to create an instance of this class inside my BPFunction it says the constructor is inacessable.
Another error says
“‘{ctor}’: illegal qualified name in member declaration” in UTracePosition::UTracePosition(USceneComponent* Arrow);
UTracePosition pos = UTracePosition(Arrow);
What’s the mistake here?