New Enum Impenemtation with TMap

Hey guys so I am having a compilation issue with UE involving an ENUM as a TMap keyvalue.
Here is my Enum

UENUM(BlueprintType)
enum class EStat : uint8
{
	ATTACK 	UMETA(DisplayName = "Attack"),
	DEFENSE 	UMETA(DisplayName = "Defense"),
	HEALTH 	UMETA(DisplayName = "Health"),
	DODGE 	UMETA(DisplayName = "Dodge"),
	AGILITY 	UMETA(DisplayName = "Agility")
};

and the Tmap using it is

TMap<EStat, int32> StatReward;

I am seeing 2 errors

C2065: ‘EStat’ : undeclared identifier

error C2923: ‘TMap’ : ‘EStat’ is not a valid template type argument for parameter

any ideas?

Where is EState declared?

Within a header file called CharBase.h but I am including it into a different header file with

#include "CharBase.h"

The class intellisense is shown so I know it is finding it correctly.

Never trust intellisense with extremely large codes :stuck_out_tongue:
try including CharBase.h in the file where the TMap is declared.

I did, I put

#include "CharBase.h"

at the top like I thought was needed, that’s why I am so confused

By any chance that that header is in a sub directory beyond classes, public or private?

By any chance that that header is in a sub directory beyond classes, public or private?

By classes, private and public I mean the folders.

Can you please post the code up to the TMap deceleration?

Same directory I, not sure what you mean by public or private it is in the header exactly how it is shown not in a class under a public: declaration.

Ok, the all are in the same folder

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once
#include "CharBase.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "QuestRewardExp.generated.h"


UENUM(BlueprintType)		//"BlueprintType" is essential to include
enum class EExpType : uint8
{
	EXP 	UMETA(DisplayName = "Experience"),
	STAT 	UMETA(DisplayName = "Stat"),
	BOTH	UMETA(DisplayName = "Both")
};

/**
 * 
 */
UCLASS()
class TERRAIN_API UQuestRewardExp : public UBlueprintFunctionLibrary
{
	GENERATED_BODY()
	
	public:


		UPROPERTY(EditAnywhere, BlueprintReadWrite)
		EExpType RewardType;

		TMap<EStat, int32> StatReward;

		UPROPERTY(EditAnywhere, BlueprintReadWrite)
		int32 ExperienceRewardAmount;
	
	
};

I just compiled an example close to yours and all is good… can you post the full paths to QuestRewardExp.h and CharBase.h?

I am unable to reproduce the problem, can you post CharBase.h please?

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "GameFramework/Character.h"
#include "CharBase.generated.h"


UENUM(BlueprintType)
enum class EStat : uint8
{
	ATTACK 	UMETA(DisplayName = "Attack"),
	DEFENSE 	UMETA(DisplayName = "Defense"),
	HEALTH 	UMETA(DisplayName = "Health"),
	DODGE 	UMETA(DisplayName = "Dodge"),
	AGILITY 	UMETA(DisplayName = "Agility")
};


UCLASS()
class TERRAIN_API ACharBase : public ACharacter
{
	GENERATED_BODY()

public:

	
	// Sets default values for this character's properties
	ACharBase();

	// Called when the game starts or when spawned
	virtual void BeginPlay() override;
	
	// Called every frame
	virtual void Tick( float DeltaSeconds ) override;

	// Called to bind functionality to input
	virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;

	
	
};

Ok I found that I need to put the enum in a class and reference it through the class. Using the code below I can now use the Enum in the TMap key value by.

 // Fill out your copyright notice in the Description page of Project Settings.
 
 #pragma once
 
 #include "GameFramework/Character.h"
 #include "CharBase.generated.h"
 
 UCLASS()
 class TERRAIN_API ACharBase : public ACharacter
 {
     GENERATED_BODY()
 
 public:

 UENUM(BlueprintType)
 enum class EStat : uint8
 {
     ATTACK     UMETA(DisplayName = "Attack"),
     DEFENSE     UMETA(DisplayName = "Defense"),
     HEALTH     UMETA(DisplayName = "Health"),
     DODGE     UMETA(DisplayName = "Dodge"),
     AGILITY     UMETA(DisplayName = "Agility")
 };
     
     // Sets default values for this character's properties
     ACharBase();
 
     // Called when the game starts or when spawned
     virtual void BeginPlay() override;
     
     // Called every frame
     virtual void Tick( float DeltaSeconds ) override;
 
     // Called to bind functionality to input
     virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
 
     
     
 };

And here is how I use it.

TMap<ACharBase::EStat, int32> StatReward;

Figured it out, see my answer post. Thanks so much!

Unreal no longer lets you define an Enum inside of a class like this. This answer should probably be deleted or something.