I’m trying to figure out how to disable or prevent equipping the same weapon twice. The reason why is because if I press the button to equip a weapon twice the third person model will stay if I un-equip or switch weapons. It doesn’t happen if I just switch weapons like normal. any suggestions?
Is the weapon being equipped derived from a weapon class? If so, create a variable (object reference) called Current Weapon. On Equip, Branch check Is Current Weapon == Pick up weapon. If false -> Set the Current weapon as the new one.
I need to see current implementation otherwise.
Here’s how I have it set up.
I guess I didn’t explain it too well, sorry about that. So I have 2 weapons at the moment, a SMG and assault rifle. They are both descended from a “base gun” BP. The way I equip them is for one actor to be destroy while simultaneously spawning the new one. This Happens for both the actual first person weapon and the models I use for a third person model. (Just for a shadow effect) The problem is after I equip a weapon and continue to press the button it will keep spawning the third person model and they won’t be destroyed if I equip the weapon again. This problem doesn’t happen if I equip it once though.
You might notice if you look at the BP on blueprintue that I added a Get All Actors of Class node so I could actually destroy all the extra models if I equipped more than once. It’s kind of a round-about fix though so I would still like a solution if there is any.
Curious if there’s any reason why you’re simply not holstering the weapons on the back of the character and switch between them? Say Slot 1 and Slot 2 of a inventory system. Just curious.
Equipped Gun (object ref) … default this to empty on begin play.
- Input Equip SMG ->
- Branch (Equipped Gun != smg obj) ->
- Branch (Equipped Gun is valid) ->
- True: destroy current equip weapon -> Spawn smg ->
- False -> pipe to “trues” spawn smg ->
- Set Equipped Gun (smg obj) ->
- Attach to socket.
Do the same logic for the Rifle.