Weapon Systems - My last hope

I have been up and down the forums/ youtube and everyone either has an inventory system where you hold infinite weapons or one that works with the “Attach actor to actor” node. At this point my computer is very close to being thrown through a wall.

Simply put all I want is a system that only allows one primary and a sidearm with infinite ammo. The sidearm isnt droppable or pickable. It is just always there. The primary is something you look at. Press the action key and it is picked up. It is droppable with the press of ctrl + “Action Key”.

Can someone please explain how to do this for a beginner? Heck Id pay one of ya to build it in an easy to understand way so I can learn.

Well… you have your weapons stored in an array, and all these weapons can be switched, picked up, reloaded, fired…

If you extend your inventory to have a static weapon with a “FireSideWeapon” call this should work fine.

Also, being picked up or have infinite ammo is something you set inside the weapon, the inventory should only hold the references and the logic to switch them, not the data.

Do you know of any good places to learn about arrays?

Array is a basic container. You can quickly find documentation about that.

https://docs.unrealengine.com/en-us/Engine/Blueprints/UserGuide/Arrays

Also, youtube tutorials

Thank you!

Would you elaborate a little for me?

​​​​​​I understand bulding a parent BP for a weapon (pick up, fire dispatcher etc to save a bunch of time)
then variables get stored in the weapon…

But when I unequip it don’t I basically destroy the actor? And I would loose things like how much ammo I had with it at the time?

I’m currently working on a twin stick with just a few weapons. Most use the same ammos (45cal, 410 shotguns, 50cal, 7.62)
Since each weapon uses the same “pool” of ammo I have stored it in the character and the weapon gets the info from it.
Is there a better way to do this?

So far weapon selected triggers a “switch on int” node that changes ammo displayed in UI and all that. It was an easy start but gets bit messy…

You can do anything and the proper way to do it depends on the feature design you want.

In your case if you have multiple ammo type belonging to your character which the weapon use, you do want to store them elsewhere than in Weapons. It makes sense since ammo is not THEIR resource but a character’s resource.

If you were to have ammo per weapon you would indeed store this weapon per weapon.

And it connects with your other question:

In your feature design you don’t need to save the amount of ammo a weapon had when it got thrown away since weapons don’t care about ammos (except if you want to keep the number of ammo it has in its clip for instance if it’s a different value than the ammo the character has).
If you do want to save the ammo in clip value, then you need to avoid destroying the weapon when it is thrown away (or to store the amount of ammo somehow).

Storing ammo in character in your case seems the right thing to do.

It sounds daunting to update when you add new type of ammo. But if you don’t it sounds okay. Another way would be to create an Enum which contains the different ammo types and use the enum to store the ammo of each type and to tell a weapon what type it uses.