Build error: Property in a struct is not initialized property (likely a simple beginner error)

In 5.1.1, when building for Windows, I get errors for each property in a struct, like this:

`Error: IntProperty FCharacterStats::SilverMedals is not initialized properly. Module:LANDNAV File:SaveGame_base_ln.h`

NOTE that I get that error for every property in the struct.

The header file defining this struct looks like this (I have snipped out most properties for legibility here, indicated with …):

USTRUCT(BlueprintType)
struct FCharacterStats
{
	GENERATED_BODY()

	//constructor
	FCharacterStats()
	{
		Archetype = "None";
		EventsCompleted = 0;
		DiamondMedals = 0;
		GoldMedals = 0;
		SilverMedals = 0;
		BronzeMedals = 0;
		TotalDistanceTraveled = 0;
		TotalDistanceWalked = 0;
		TotalDistanceSkied = 0;
		TotalDistanceBiked = 0;
		TotalDistanceKayaked = 0;
		TotalDistanceClimbed = 0;
		TimesExhausted = 0;
		TimesInjured = 0;
	}
	
	UPROPERTY(EditAnywhere, BlueprintReadWrite)
	int EventsCompleted;
	.....
	UPROPERTY(BlueprintReadWrite, EditAnywhere)
	double TotalDistanceTraveled;
	....
};

This struct is used in a save game class and I set the default values in a blueprint child of this c++ class. Save and load works normally in PIE.

Blueprint child setting the default values:

I added the constructor because I have read that perhaps the properties need to be explicitly initialized, however it does not seem to change the errors I get when building.

I am not super experienced with C++ so it’s most likely that I’ve just missed something basic. Any tips are appreciated.

additional:
Here is where the struct is added to the save game class. I have not done anything in a .cpp file.

UCLASS(Blueprintable)
class LANDNAV_API USaveGame_base_ln : public USaveGame
{
	GENERATED_BODY()

public:

	//STRUCTS

	// characters are in order of A, B, C, D, E, F, G, H
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Characters")
	TArray<FCharacterSkills> CharacterSkills;

	// characters are in order of A, B, C, D, E, F, G, H
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Category= "Characters")
	TArray<FCharacterStats> CharacterStats;

I got a successful build even though I did not fix this, so I am not sure what to think.

For one of the structs I made a contructor in the structs definition and then call that constructor in the save game classes constructor.
However, I only did that with one struct, not the others, and yet those errors have dissappeared.

I also had some other struct related errors (unknown struct error) related to some blueprint structs. For those I just did Refresh All Nodes in the blueprints and recompiled.

Now game has packed successfully. So I am not sure if the struct initialization was even a thing or just resulting from some other dependency not being set up first.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.