How to write constructor for custom struct

SiberianExpress
Thu, 17 Dec 2015 18:24:06 +0000
C++

I created a custom struct “FIntVector2D” simply a 2D integer vector using the FIntVector template.

file ObjectLib.h

>     #include "Engine/ObjectLibrary.h"
>     #include "ObjectLib.generated.h"
>
>     USTRUCT(immutable, noexport, BlueprintType)
>     struct FIntVector2D
>     {
>     	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IntVector2D", SaveGame)
>     		int32 X;
>
>     	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IntVector2D", SaveGame)
>     		int32 Y;
>     };

That works fine, I can use it the way I want to in Unreal, but I would like to have a constructor such as

FIntVector2d(10, 20);

I have been trying to copy the code from the default FIntVector but can’t for the life of me figure out the exact code thats needed and where to put it.

Hope someone can help or at least point me int eh right direction.

3 posts - 3 participants