Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Bitmask Enum incorrect values

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")

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:


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?

Product Version: UE 4.13
more ▼

asked Sep 22 '16 at 09:23 AM in C++ Programming

avatar image

102 11 15 23

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Having looked around a bit more, it seems this issue is covered by bug UE-32816.

The bug outlines that it is actually as intended functionality, and the bitmask values, rather than 1, 2, 4, 8 .... it should simply be 1, 2, 3, 4, 5.... where the value is actually interpreted as 1 << N rather than N itself.

I'm unsure if I should delete my post at this point or leave this here for posterity.

more ▼

answered Sep 22 '16 at 04:07 PM

avatar image

102 11 15 23

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question