Passing an Enum as Parameter into a UFUNCTION

So I am trying to create a blueprint enabled method with C++ but I am running into a Missing ‘*’ error that is breaking solution.

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

#pragma once

#include "Kismet/BlueprintFunctionLibrary.h"
#include "CharacterStats.generated.h"

/**
 * 
 */
UCLASS()
class TERRAIN_API UCharacterStats : public UBlueprintFunctionLibrary
{
	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")
	};
	
	
	
};

Now in my base class a am creating the function.

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

#pragma once

#include "CharacterStats.h"
#include "GameFramework/Character.h"
#include "BaseCharacter.generated.h"



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

public:

	UFUNCTION(BlueprintCallable, Category = "Stats")
	void SetPlayerStat(UCharacterStats::EStat Stat, int32 Amount);

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

	// 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;
	
};

No mater what I do I keep getting “Missing ‘*’ in Expected a pointer type” error. If I remove the UFUNCTION it compiles fine.

I get the same error exactly if I add the *

	void SetPlayerStat(UCharacterStats::EStat* Stat, int32 Amount);

Help Please!!!

Reflection system only support specific types, thats why you get error from UHT (not compiler) when you use it with UFUNCTION().

Remove “class” and “: uint8” from enum declaration (reflection system does not support enum classes) and in function place

TEnumAsByte<UCharacterStats::EStat> 

as well anywhere else when you use enum as varable in reflection system. I’m not sure if you can use Enum inside class, i did that myself and not sure if it’s gonna work (it might build with UENUM(), because UHT ignore it thinking it some macro inside class and compiler ignore all reflection macros), if not then move it outside of class

Thanks for explaining this.
I am now seeing a “Expected the name of a previously defined enum” for

UFUNCTION(BlueprintCallable, Category = "Stats")
void SetPlayerStat(TEnumAsByte<UCharacterStats::EStat>  Stat, int32 Amount);

I did try to remove the UENUM(BlueprintType)

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

#pragma once

#include "Kismet/BlueprintFunctionLibrary.h"
#include "CharacterStats.generated.h"

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

public:


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



};

Hey -

If I understand correctly you’re trying to create a function that can be called inside a blueprint that takes in an Enum as a parameter? Using the Enum you posted and 's suggestion I was able to compile a function successfully. I copied your Enum and used 's suggestion of removing “class” and “uint8” from the Enum declaration. This was placed outside of the class declaration rather than inside. Inside the class I was able to create the following function which compiled and was usable in the editor:

UFUNCTION(BlueprintCallable, Category = Test)
	void TestFunc(TEnumAsByte<EStat> Compiled);

61757-enumnode.png

Let me know if this is the functionality you are trying to achieve or if there is something I’ve missed about your issue.

Cheers

Moving out of the class was the Key!
Working now Thanks both of you!