Looking for Ways to Create a Numbered Inventory in a Shooter

On my current project I’ve been trying to figure out how to make a weapon inventory similar to those found in shooters like UT or Quake, where each weapon corresponds to a number and picked-up weapons can only be accessed from their intended slot.

The idea I landed on was creating an enum that stores the names of each weapon, and adding those names as gameplay tags to the BP children of my base weapon class. Then, when a weapon gets picked up a for loop goes through the enum and checks if the actor’s tag is a match. If so, then the weapon is placed into an array element that is the same as the matching enum’s element. Problem is, this only works for weapon #2 and picking up a weapon out-of-order results in a swift UE crash.

I figure it’s because my array where pointers to weapons are stored doesn’t have enough elements if I pick up a weapon that “skips ahead”. I’ve tried initializing a few default and zeroed elements in BeginPlay to avoid it, but that hasn’t worked either. Can anyone help me out? Chances are my idea as a whole isn’t great :sweat_smile: