How does Unreal Engine handle two of the same value in a map?

I am using maps to sort weapons by their unlockable level. I have ran into a little bit of a roadblock, where two weapons are unlocked at level 0. I am using the Map “Find” Function to find the map key by the unlocked level value. When there’s two of the same value, this find outputs only one of the elements. I have tried removing the element by value after getting it, so I can get both level 0 keys, but apparently removing a map key by value removes EVERY element with the value 0, so even the second one that wasn’t even found yet.

How would I go around fixing this issue, and how do maps and values work in Unreal Engine in general?

Hi ,
You can only have one of each key in a Map - if you want multiple items of each key you’ll need to make a Map of Arrays - or make a simple struct with an Array of the weapons, and make it a Map of that Struct.

1 Like