Weapon swap

Hey there,

Enums are pretty much like arrays of integers (bytes actually), but they have a friendly name. In your case, you have (if you set it up in order in the screen) something like this:

0 = Shotgun
1 = Assault Rifle
2 = Granade launcher
3 = Sniper Rifle
4 = Rocket launcher

So what you have to do is, whenever you press the key you want to get to the next weapon, to add +1 to your Weapon Type (but only if you are not on the last index, e.g. you’re not in rocket launcher; otherwise you will be in index “5” which is empty). So you’ll have to:

  1. When you press a key (e.g. mouse wheel up), check if we are in the last item.
    1.A) If we are NOT in the last item, add +1 to the enum.
    1.B) If we are in the last item, reset the enum (get back to 0).

I made a simple set up with a similar enum, hope this helps.

Edit: sorry, the comment in the branch is wrong, it’s the opposite: Are we NOT in the last index?