Download

Issues with Custom Constructor for USTRUCT()

Hi

Anyone know why im getting

error C2248: ‘UBlockSet::UBlockSet’ : cannot access private member declared in class ‘UBlockSet’

.H


UCLASS()
class QUARTH2_API UBlockSet : public UUserDefinedStruct
{
	GENERATED_BODY()

	public:

	
	UBlockSet::UBlockSet(float x, float y, TMap<int32, int32> columns, float maxX, float maxY);

	//<Column, RowsInColumn>
	UPROPERTY()
	TMap<int32, int32> BlockPosition;

	UPROPERTY()
	float StartLocationX;

	UPROPERTY()
	float StartLocationY;

	UPROPERTY()
	float MaxX;
	
	UPROPERTY()
	float MaxY;



};

.CPP



UBlockSet::UBlockSet(float x, float y, TMap<int32, int32> columns, float maxX, float maxY){
	StartLocationX = x;
	StartLocationY = y;
	BlockPosition = columns;
	MaxX = maxX;
	MaxY = maxY;
}


Usage is the following



TMap<int32, int32> BlockPosisitions;
UBlockSet currentSet = UBlockSet((blockSet * 100 + 50), 2000.f, BlockPosisitions, totalColumns * 100 + 50, colxHeight);

… I wasnt using a USTRUCT()

What is the UserDefinedStruct class anyone know?

You are not using the proper ue4 macros for a USTRUCT


USTRUCT(BlueprintType)
struct FPoint
{
	GENERATED_USTRUCT_BODY()
	
	UPROPERTY(BlueprintReadWrite)
	int32 x;

	UPROPERTY(BlueprintReadWrite)
	int32 y;

	FPoint(double x_, double y_) : x(x_), y(y_) {}
	FPoint() : x(0), y(0) {}

};

The above is an working struct in my code.