I’ve spent a few hours looking up documentation on how to create ustructs in header files, though I’m always faced with some sort of error. 's an example of some code I’ve been using.
#pragma once
#include "GameFramework/Actor.h"
#include "TestActor.generated.h"
USTRUCT()
struct Coordinate //Used as a coordinate, has X/Y value.
{
UPROPERTY()
int32 X, Y;
int32 GetX()
{
return X;
}
int32 GetY()
{
return Y;
}
Coordinate(int32 X, int32 Y)
{
this->X = X;
this->Y = Y;
}
//Implement garbage collection later on
};
UCLASS()
class ROGUEPROJ2_API ATestActor : public AActor
{
GENERATED_BODY()
public:
ATestActor(); // Sets default values for this actor's properties
virtual void BeginPlay() override; // Called when the game starts or when spawned
};
I created an Actor and attempted to write in some structs into the header file, but I’m still getting errors. Am I supposed to use another type of base class, such as a component? Furthermore, if I want a separate file containing my structs (which I could probably use #include in other classes), how can I implement it through UE4? All the documentation I’ve seen goes over the code itself, but I’m still unsure as to the specifics from within the editor (such as the base class chosen to build this code upon, where things are saved, etc)