enum ESuitType : uint8
should be enum class ESuitType : uint8
Hello, I made two enum with the UENUM macro and it seems to produce the error: Missing ‘{’ in ‘Enum’, I don’t know why. I created the same enums in the class, without the macro and it works, but since I want to be able to access the enums in blueprint, I need the macros. I read some posts about this kind of error but it was with earlier versions of the engine and I haven’t found any a fix. So, does someone know how to fix this ?
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "GameFramework/Actor.h"
#include "Suit.generated.h"
UCLASS()
class GMPL_API ASuit : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ASuit();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick( float DeltaSeconds ) override;
public:
//Properties
UPROPERTY(EditAnywhere, Category = "Weapons")
USkeletalMeshComponent *WeaponMesh1;
UPROPERTY(EditAnywhere, Category = "Weapons")
USkeletalMeshComponent *WeaponMesh2;
UPROPERTY(EditAnywhere, Category = "Weapons")
USkeletalMeshComponent *WeaponMesh3;
UPROPERTY(EditAnywhere, Category = "TEST")
USkeletalMeshComponent *TEST;
UPROPERTY(EditAnywhere)
USceneComponent *Component;
//Functions
void EquipSuit(ESuitType SuitType, float ProtectionAmount);
private:
//Properties
float ExplorationProtection = 700;
float InfiltratorProtection = 200;
float CombatProtection = 1000;
};
UENUM(BlueprintType)
enum ESuitType : uint8 //Here is the error
{
Exploration UMETA(DisplayName = "Exploration"),
Infiltrator UMETA(DisplayName = "Infiltrator"),
Combat UMETA(DisplayName = "Combat")
};
UENUM(BlueprintType)
enum EWeaponType : uint8
{
Riffle UMETA(DisplayName = "Riffle"),
Shotgun UMETA(DisplayName = "Shotgun"),
Knifes UMETA(DisplayName = "Knives")
};
It worked, but now I get a syntax error on my EquipSuit function with the ESuitType indentifier. Is there a way to declare this identifier properly ?
ESuitType
is defined after EquipSuit
. Either move your enum above your class, or forward declare your enum above your class using enum class ESuitType : uint8;.
Well, apparently moving the enums declaration above the UCLASS resolved the problem.