Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Weapon Contains The Ammo Inside?

How do I make a weapon contain its ammo in the magazine and the ammo you had for it in the weapon itself.

So like AK-47 gun has 30/30 ammo in the magazine and 360/500 ammo in the inventory,

Shoot 3 rounds now the weapon is 27/30 (In the magazine) then when the weapon is dropped the magazine ammo is still 27/30 and the bullets in the weapons inventory is 360/500 when another player picks it up they will have the amount of magazine ammo and weapon inventory ammo what you had before dropping the weapon,

A player finds the dropped weapon picks it up, AK-47 magazine contains 27/30 bullets plus an inventory of 360/500 7.62x39 so you can now reload and get 30/30 in the magazine and 356/500 in the weapons inventory.

How can I make the weapon keep the magazine ammo and the inventory ammo?

I noticed this system is how a game called Killing floor dose it for all its weapons so that you can drop your weapon for another player:


How would I go to make this work to have the weapon store ammo in the magazine and the ammo inventory in itself?

Product Version: UE 4.22
more ▼

asked May 13 '19 at 03:32 AM in Using UE4

avatar image

20 1 1 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

Thats the reason why most game don't care about single ammo count magazine, instead count single bullets for weapon, limiting amount of ammo you can fire before reload, and ammo change is just visual animation, i requires more complex system which is usually not needed for the game

It all depends on you pickup and inventory system (and no body gonna tell you "how" to do it as they don't know how it works which you didnt describe, we can only speculate here), if you store individual ammo magazines as individual inventory items then this is simple, pick first most full ammo magazine and store reference ot it in weapon do it use it and deceres ammo from magazine item, on reload pick next most full ammo. If you don't want to keep used ammo magazine in inventory, make inventory slot on weapon it self (object reference variable, same as you may do with used weapon), where you drop it, make that ammo being held in weapon pick up too.

In most simplest form, you could have seperate ammo count for weapon and inventory, when you reload, subtract amount of missing weapon ammo from inventory. When you drop weapon you store that value on it's pickup. And can assume that player will give full magazines of ammo until they give there last one which is incomplete and substruct amount of inventory ammo from inventory and last one substact from weapon count, or drop weapon all toghther.

Think how this suppose to work and just try to program that and divide ammo storage as much as you need to execute to make it work as you want it to work

more ▼

answered May 13 '19 at 04:36 AM

avatar image

36.6k 931 169 1111

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question