I created an enum with 4 members.
When I attempt to get an array of all the values in the enum, my ‘GetValues’ will not seem to work. Upon reading, I cannot find where I have messed up. I get the error on build that says:
‘GetValues’: is not a member of ‘UEnum’
Code from .h
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "Engine/Texture2D.h"
#include "UObject/Class.h"
#include "UObject/ObjectMacros.h"
#include "Kismet/KismetMathLibrary.h"
#include "CaptainComponent.generated.h"
// Archetype Enum
UENUM(BlueprintType)
enum class ECaptain_Archetype : uint8
{
FleetCom, Militarist, Statesman, Omnivisor
};
// Focus Enum
UENUM(BlueprintType)
enum class ECaptain_Focus : uint8
{
Culturalist, Economist, Mercenary, Philsopher, Rebel, Soldier, Spiritualist
};
// Captain Struct
USTRUCT(BlueprintType)
struct FCaptain
{
GENERATED_BODY()
// Captain Name
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Captains")
FString CaptainName;
// Captain Quote
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Captains")
FString CaptainQuote;
// Captain Description
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Captains")
FString Description;
// Captain Archetype
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Captains")
int32 Archetype;
// Captain Focus
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Captains")
int32 Focus;
// Reserved Stat 1
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Captains")
int32 Stat1;
// Reserved Stat 2
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Captains")
int32 Stat2;
// The image of the captain
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Captains")
UTexture2D* Image;
};
ECaptain_Archetype GetRandomCaptainArcheType()
{
// Get an array of all the values in the Archetype Enum
TArray<ECaptain_Archetype> values = UEnum::GetValues<ECaptain_Archetype>();
// Generate random integer between 0 and the number of values in the enum
int32 randomIndex = FMath::RandHelper(values.Num());
// Returns random value from enum
return values[randomIndex];
}
This is the failing line of code: TArray<ECaptain_Archetype> values = UEnum::GetValues<ECaptain_Archetype>();
Any help would be appreciated