Download

Convert enum to uint8

Hello. I have an enum class ECustomMovements:


UENUM(BlueprintType)
enum class ECustomMovements : uint8 {
    GRAPPLING   = 0            UMETA(DisplayName = "Grappling"),
    OTHER       = 255          UMETA(DisplayName = "Other")
};

What I am trying to do is set my movement mode to a custom movement mode, whose second parameter takes a uint8 to denote which custom movement mode I’m switching to:


Player->GetFPCharacterMovement()->SetMovementMode(
    EMovementMode::MOVE_Custom, ECustomMovements::GRAPPLING
);

Whenever I try this, I get “cannot convert argument 2 from ‘ECustomMovements’ to ‘uint8’”.

I vaguely remember this working fine about half a year ago. Am I doing something wrong? I want to be able to use the enum in place of a uint8 since this will be used across many classes.

uint8 byte = (uint8)ECustomMovements::GRAPPLING;

Then use that “byte” var instead.

I thought I tried this, but apparently not. Thanks!