Is there a way to create an Enumerator in Blueprints? for example, i’d like to build a state machine, and right now i’m just using ‘name’ type variables to get/set the state, but as an alternative to this, i was interested in creating a custom type, and then checking for that type in some sort of drop down menu within a blueprint function so i could verify consistency between classes when i cast. or maybe there is a better way to handle this in blueprints?
Easy as pie!
Right-click in the My Blueprint/Variables area and select Create Enum Asset. This will actually create an Enum .uasset in the same folder as the Blueprint it was created in. This Enum can be shared between blueprints as well! Then, use the Switch on Enum macro and you’re off to the races!
wow. that was exactly what i was looking for. thanks Tom! btw, i followed some of your work over at PB awhile ago. pretty cool and inspiring.
Hey, thanks! Now I feel famous!
Are these Enums global across all the BPs? Meaning if my level or game mode or some other BP sets the Enum, then can my HUD BP listen for the change or do I need to pass that information through with an interface event etc?
you might want to use an event dispatcher for that.
the custom enum is available between classes. however i think you actually want access to whatever variable is holding the ‘current enum type’.
set the current type, and tell the world it’s been set
bind the dispatch event to the hud and do stuff when it’s triggered
What he said…
Um, does this Create Enum Asset thing still exist? I don’t see it when I right-click there.
I found it. They moved the option:
One answer shows that it’s moved to Content -> Add New
Content -> Add New -> Blueprints -> Enumeration to be precise.