I encountered my favorit error again.
I thought I did fix my setup now using a UStruct instead a UClass, but this dont seem to fix my problem.
I have no really no idea what is causing this error.
I try to make a n-dimensional vector, which works like the FVector, so I looked into Vector.h and KismetMathLibrary and KismetStringLibrary and build the following setup:
NVector.h:
#pragma once
#include "NVector.generated.h"
USTRUCT(BlueprintType)
struct FNVector
{
GENERATED_BODY()
/* nVector's components. */
UPROPERTY(BlueprintReadWrite)
TArray<float> Coordinates;
/* Default constructor (no initialization). */
FORCEINLINE FNVector();
/* constructor to set n-Dimensions */
FORCEINLINE FNVector(const TArray<float> InCoordinates);
FString ToString() const;
};
FORCEINLINE FNVector::FNVector()
{}
FORCEINLINE FNVector::FNVector(const TArray<float> InCoordinates)
: Coordinates(InCoordinates)
{}
FORCEINLINE FString FNVector::ToString() const
{
FString s = "";
s += "{";
for(int i = 0, max = Coordinates.Num(); i < max; i++)
{
s += FString::SanitizeFloat(Coordinates[i]);
if(i < (max - 1))
{
s += ", ";
}
}
s += "}";
return s;
}
MathLabLibrary.h:
#pragma once
#include "Kismet/BlueprintFunctionLibrary.h"
#include "Math/NVector.h"
#include "MathLabLibrary.generated.h"
UCLASS()
class MATHLAB_API UMathLabLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
/* Converts a n-vector value to a string, in the form '{x, y, z, ...}' */
UFUNCTION(BlueprintPure, DisplayName = "ToString (nVector)", Category = "Math Lab|Utilities|String", meta = (CompactNodeTitle = "->", BlueprintAutocast))
static FString Conv_NVectorToString(FNVector InVec);
};
MathLabLibrary.cpp:
#include "MathLab.h"
#include "MathLabLibrary.h"
FString UMathLabLibrary::Conv_NVectorToString(FNVector InVec)
{
return InVec.ToString();
}
When I go now into a Blueprint, in my case CoordinateSystem, and want to use my structure like this:
(Compile Blueprint, everything works)
When I than change something in my Code and try to Compile the Blueprint, I get following Error:
I have no idea what is causing the error Message. I tried to understand the logic how the FVector is created and works and copy that for my NVector.