Pickup the weapon with the highest priority

Hi friends! I think you can help me.

I’ve some “Pick Up Weapon” Actors with Box Component. I pick up a weapon if I press a button when I’m inside the box (every “Pick Up Weapon” Blueprint uses “OnComponentBeginOverlap” for enable input).

Now i would make something like this:

  • gun priority = low (Integer= 1)
  • rifle priority = medium (Integer= 2)
  • RPG priority = high (Integer= 3)

because I want pick up the weapon with the highest priority level when I’m inside many Box Component at the same time.

I think I need a BP Interface, because I’ve seen this thread: Blueprint Catch - Blueprint - Epic Developer Community Forums but I would make a simple priority system between the Character BP and every Pick Up Weapon BP…can someone help me?

Please, let me know.

Try to use GetOverlappingActors when pressing pickup. Then iterate through the array and cast it to your weapon interface. Add some method to the interface like GetPickupPriority.

One implementation would be to create a local variable that you overwrite when finding a weapon with higher priority than the current and then return this weapon when there is no more weapons to iterate through.

Hi Undercover, many thanks for your help!

No problems. Glad I could help =)