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"

Difficulty with modular ammo

Im attempting to add ammo to something Im working on, but I want ammo and its stored value (maxAmmo) to be separate from the player and the players weapon. I would like to be able to create a ammo blueprint, and have all the info for that specific ammo type stored within it, such as max ammo, damage, sound, ect. How might I go ahead and do this so I can have my player blueprint receive values out of it so my HUD can read the ammo, as well as how can I have my weapon blueprint access this information in the ammo blueprint?

Product Version: UE 4.13
more ▼

asked Oct 04 '16 at 02:38 AM in Blueprint Scripting

avatar image

245 41 52 65

avatar image Shirk Oct 04 '16 at 05:35 PM

I currently have my entire weapon system working and functional, the only thing I am stumped on is how to handle the ammo for everything. I know how to get the value and send it to my HUD so it can be displayed, my issue is actually figuring out how to store the total ammo available to the player in a blueprint that I can still access from the player, and from the gun itself.

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

2 answers: sort voted first

if what you want is just to create a different class to store the information about the ammo, it's actually very simple, just go to add new->blueprint then select actor as parent class, give a name to it, and then you should want to add a "ProjectileMovement" component (it will make the ammo "fly" by itself and you can control the speed and things like this), implement what you need (you probably need to at least do something at generate overlap event, to damage someone or things like this), you have to choose, maybe you want to store your ammo in a inventory or something like this, in this case i would suggest you to create a class to inventory, and things can get more complex this way, or you gan just create a variable for the ammo in your weapon and use "get" to acess the variables in the ammo class, and then create a variable for the weapon in your character (you can acess the ammo acessing the weapon and then the ammo).

if you aim to create a game with a lot of different weapons and bullets and all this shit you should search about inheritance

but an easier way to understand is following the "twin stick shooter tutorial", there's a system similar to what you want there: http://docs.unrealengine.com/latest/INT/Videos/PLZlv_N0_O1gb5sdygbSiEU7hb0eomNLdq/

more ▼

answered Oct 04 '16 at 01:32 PM

avatar image

1.1k 31 18 66

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

You could make a ActorComponent. Put all the Ammo logic and variables of your ammo in there. Then you can add the ActorComponent in your weapon blueprint.

In the player character blueprint you can make a WeaponBP variable that has a reference to the weapon the player is currently holding(set this when you pick up the weapon).

Assuming you are using the FirstPerson Template: In the HUD you can then GetPlayerCharacter->CastToFirstPersonCharacter->Get WeaponBP variable ->Get AmmoComponent.

more ▼

answered Oct 04 '16 at 10:01 AM

avatar image

6 1 2

(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