More Elegant Solution to State Switching?

Hi all, Hoping to get some help with switching combat states. I have it working now, but the solution is hacky. Wondering how to cycle backward and forward through states (or bool variables for that matter) via Enum. I’v messed around with Switches but haven’t had any luck getting them to work properly… Any help would be appreciated. Here’s what I’m trying to do, but better:

Hi,
if converted your blueprint to an enum-version which works backwards, as well.

Enum:

Forwards:

WeaponState is an instance of the enum created above.

NumberOfStates is a Byte variable used as constant. It is set to 4 in this case.

You can basically give any byte into an enum, and it will switch to the state with that index( starting with 0). It is kinda like an array with fixed values.

Unlike an array i havent found any solution to get the lenght of the enumeration, so i had to give it in manually.

Every time the index would get greater than the actual size of the enum, it is set back to the first index.

Backwards:

Same as above but backwards :smiley:

Very cool, you rock! Thanks.

Unfortunatly commenting unmarks the answer as correct.

From DrifterGames’ reaction, it appears this was the right answer, so I’ll mark this as accepted.