I’m really new to c++ but I do have a lot of experience with python. I’m trying to basically just create a struct, then create and fill a variable with that struct that I can access in Blueprint.
I don’t know if I need to declare the variable beforehand or what, but this is what I have (which is failing to build). The error I’m getting is “Incomplete type is not allowed” for FBaseCharacterStats.
I want to then serialize the data from the struct into a string like so:
// Serialize Base Character Stats to an FString
UFUNCTION(BlueprintCallable, Category = "Stats")
FString SerializeBaseCharacterStats();
// Deserialize an FString to Base Character Stats
UFUNCTION(BlueprintCallable, Category = "Stats")
void LoadBaseCharacterStatsFromJSON(FString BaseCharacterStatsJSON);
This is in the Character.h file:
struct FPPBaseCharacterStats
{
GENERATED_BODY()
public:
FPPBaseCharacterStats()
{
Strength = 5;
Perception = 5;
Endurance = 5;
Charisma = 5;
Intelligence = 5;
Agility = 5;
Luck = 5;
Willpower = 5;
}
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Stats")
int32 Strength;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Stats")
int32 Perception;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Stats")
int32 Endurance;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Stats")
int32 Charisma;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Stats")
int32 Agility;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Stats")
int32 Intelligence;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Stats")
int32 Luck;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Stats")
int32 Willpower;
// create variable that can be accessed in BP and fill with struct
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Stats")
FPPBaseCharacterStats BaseCharacterStats;
};