I have a bitmask enum I’ve declared in the following manner:
UENUM(BlueprintType, meta = (Bitflags))
enum class EDoorKeys : uint8
{
Key1= 1 UMETA(DisplayName = "Some Key"),
Key2 2 UMETA(DisplayName = "Some Key 2"),
Key3 = 4 UMETA(DisplayName = "Some Key 3"),
Key4 = 8 UMETA(DisplayName = "Some Key 4"),
Key5 = 16 UMETA(DisplayName = "Some Key 5"),
Key 6 = 32 UMETA(DisplayName = "Some Key 6")
};
ENUM_CLASS_FLAGS(EDoorKeys)
I’m using in an actor as follows:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Variables|Inventory",
meta = (Bitmask, BitmaskEnum = "EDoorKeys"))
int32 currentKeys2;
However when I’m checking its values as I’m manipulating it, Key1 maps to a value of 2; Key 2 maps to a value of 4; Key3 maps to a value of 16; Key 4 maps to a value of 256; Key5 maps to a value of 65,536 and Key6 is unusable.
Oddly, when I print out the value of one of the enum values on its own I.e:
GEngine->AddOnScreenDebug(....FString::FromInt((int)EDoorKeys::KeyX);
It prints out the value I would expect, Where X is 1 or 6, I’d get 1 or 32.
I’ve tried changing the values to use a hexadecimal value instead in case that did something, but to no avail, I also tried using the actor variable as a uint8, but then I only have access to the first 3 options. Does anyone have any ideas?