Problem with multiple weapons

I’m having a really weird issue. I have things setup using 2 weapon inventory slots, WeaponEquipped (The held weapon) and WeaponSecondary (One on your back). I have no problems with collecting the weapons and having them fill the correct slots and all is good.

The problems begin when I try to start with a weapon in the Equipped slot. When I spawn the weapon, set it to fill the WeaponEquipped variable and attach it to the socket, it shows up properly. When I pick up a new weapon though, it is no longer sending it to the WeaponSecondary back slot and is adding it to the one in my hand. Here is the node layout for my weapon spawning, which is being handled inside by Character BP:

And I end up with a situation like this:


The weird thing is, if I remove the SpawnActor node and simply do a cast to the Machinegun_BP and keep everything from the Set WeaponEquipped onward, everything works properly but I don’t actually have an equipped weapon ingame, just logic that tells the game that the variable is populated.

My pickup, variable assignment and socket attachment logic is as follows:

The first part, the Collect Function, resides inside my Character BP.

The second part, the Overlap Event, is inside my Weapon BP.

For some reason I just can’t get this to work. Any ideas?

Ok, so I solved the stacking issue. I had completely forgotten to destroy the actor before setting a new WeaponEquipped in my Collect Function.

The problem now is that it will always replace my spawned weapon before setting the picked up weapon as the WeaponSecondary. So basically it’s still not seeing the weapon I’m spawning with as being a valid WeaponEquipped and is proceeding to overwrite that first before populating the second weapon slot.

Hi ,

Thanks for the response. So I changed over the node to use the function but it’s still doing the same thing. When I got the display name of the WeaponSecondary variable and told it to print, it gave me the name of the spawned BP that I had assigned to the WeaponEquipped slot on BeginPlay.

It’s not ideal, but what I’ve done is then manually set the WeaponSecondary variable to NULL after the weapon has been spawned and attached and that seems to be a workaround for the time being. Not sure why that variable is being auto-populated though.

Hey there ,

Let’s take a look at the blueprint node “? is valid” in the Collect function, change that over to the blueprint node of “Is Valid” (where “Is Valid” has the green “f” in front of it, not the ?). They both take a object reference, and let’s see, if that fixes, by detecting that the passed object doesn’t actually exist.

If it still fails in the same fashion, insert one more check after the new Is Valid blueprint node, and that is to get the display name for the object, and check that the length of the returned string is greater than zero. I know I wrote my own “Is Valid” blueprint node, in order to take care of some anomalies with the standard library.