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?
asked Oct 04 '16 at 02:38 AM in Blueprint Scripting
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/
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.
answered Oct 04 '16 at 10:01 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here