Hello,
I’m trying to create a weapon pickup system that behaves similar to Call of Duty or Halo, where you stand near a weapon on the ground and you see a prompt on the screen. You hold down your interact key and it picks up the weapon. When you already have two weapons, it replaces the currently equipped weapon.
I’ve got a system already partially set up, but I’m not sure if I am on the right track. In my parent weapon class, I have a collision sphere that is tied to OnComponentBeginOverlap and OnComponentEndOverlap events, which modifies an array within the Character Blueprint. A custom event is also called to within the Character Blueprint to spawn and remove a UMG widget. Below is my Blueprint:
This seems to be the best way to do this, as it allows two or more players to stand within proximity of the weapon and be able to interact with it. Obviously when two players try to pick up the weapon at the same time, the server would only allow the first player to pick up the weapon.
Below is the custom event within the Character Blueprint:
NearInteractableActors is a macro that simply returns false if the InteractableActors array is empty. With the code above, the UMG widget appears and disappears from the screen for all players in the game when one player overlaps a weapon. I guess this is because a Character actor exists for each player in the game. By adding an IsLocallyControlled check into the execution chain, it behaves as expected, but I’m getting an The widget ‘WBP_Interact_C’ was already added to the screen. warning and I’m not sure why.
Am I on the right track here with this method?