Download

How do you connect booleans to enum values?

I have a state machine that uses booleans to enter different states. How do I connect these booleans to a list of enums. For example.

A list that is:

0: None
1: Unarmed
2: Armed

I have one boolean variable in the state machine that is called entering combat. if it is true I want it to equal armed. If it is false I want it to equal unarmed.

Thanks!

Is this done in the character blueprint, animation blueprint event graph, or animation blueprint in the state machine transitions? I’m just not sure on how to set this up. Any help would be appreciated.

A quick sample would help too, like a basic blueprint picture. I’m not smart so visually I can understand it better lol.

Enums get converted to a set of integers so by default the names in your enums list will be converted to 0, 1, 2, 3… Booleans have a value of true or false, although this is sometimes represented as 0, 1… So you can’t convert from one to the other directly…

If you want to convert from an enum to a boolean, drag off from your enum variable, and type “switch on [enum name]”, this will give you a node with an exec output for each enum value, you can then set the boolean you want to the value you want from that exec path…

If you want to convert from boolean to enum you will have to use a branch node from your boolean variable, then set your enum to the desired value on the branch outputs…

ps:

I just noticed you didn’t have any enum types in your screenshot, so just wondering if when you mentioned enums you just meant conceptually (just in case, you can create an enum type from “Content Browser > Add New > Blueprints > Enumerators” then in your blueprint create a new variable and in the variable type drop down type in your enum name).

Also noticed that you had a long list of booleans for various states, if these states are mutually exclusive, these would be perfect to implement using an enum, as having this many booleans will be quite hard to manage…

Some screenshots…

In anim graph…

OH! THANK YOU SO MUCH! Yeah I figured I approached this the wrong way. Your explanation makes perfect sense! Yeah the booleans were too many and I knew something wasn’t right and I just didn’t have the right approach. Thank you very much. Much appreciated!