Hello everyone , i’ve been working on Gameplay for my Game and i’ve been following some tutorials scattered around youtube / forums etc. to create the mechanics im after.
I’ve found a really good tutorial series about creating an inventory / weapons etc. on this Website Tutorials | Shooter Tutorial
With the Inventory system that this fella created it was not possible to create WeaponPickups to add to inventory and i’ve fixed that.
but now i got a greater problem , somehow i cant create Ammo pickups.
in this tutorial "on the website is number6 Weapon Shooting and Reloading functionalities.
we create / modify the BP_BaseWeapon
in the Baseweapon we also create some variables that are CurrentAmmoInMag , MaxAmmoInMag , CurrentAmmoInBackpack , MaxAmmoInBackpack all these variables are Integers
after this we need to open BP_Weapon_Pistol that is a Child Blueprint of BP_BaseWeapon.
in this child blueprint i inherited all the variables from BaseWeapon and im able to modify them suiting what kind of weapon im currently using “its really handy”
but here’s my problem.
Following the tutorial. the only way to start / get ammo.
is in BP_BaseWeapon to setup an event begin play to set the max ammo in mag as current ammo in mag , and the Max ammo in backpack , as current ammo in backpack
this way as soon as i test the game , and equip the pistol that i pickup from the ground i got the ammo “great”.
problem number 1 , when i remove it from inventory and i re-equip it i get all the ammo back , also if i switch it from slot. and i dont want that.
problem number 2, i have no idea on how to create an ammo pickup for this type of setup.
if i disconnect event beginplay to set all those ammo that way , and i equip / unequip or switch slot of the pistol i dont get any ammo “and thats ok”
i tried to create a Pickup actor , also before doing that i’ve set all the variables on editable / public hoping that it would change something but i just cant get it to work.
in the test Pickup i created a CollisionSphere , with a static mesh “just a pistol magazine”
and
OnComponentBeginOverlap(Sphere) its my problem.
there’s no way i can cast it to BP_Weapon_Pistol. its just not working , and i cant modify the CurrentAmmo in backpack Variable since its only existing in the BP_BaseWeapon.
the only way i found out to get ammo by pickup.
is this
http://imgur.com/a/zP5yT (Blueprint that should act as Pickup)
http://imgur.com/a/r7Q1m (BP_WeaponPistol to call the event)
This way “yes” i can pickup ammo , but i recreate the original problem of , everytime i remove from inventory , or switch slot , the ammo of the weapon reload automatically.
even tho this part gets the pickup to work.
at first i thought it was simple. just to set the variable to the desired amount of ammo i wanted to pickup Casted to BP_WeaponPistol or BP_Base_Weapon and i would get my ammo.
but casting to either pistol or baseweapon doesnt work , and the only way to make the ammo pickup is on how i show on screenshots. but i got many issues with this.
I Really hope someone Way better than me in blueprints can point me to a solution. this thing is driving me crazy and im feeling stupid.
For any additional info i can post screens etc… just help me in desperate lol
EDIT: After Updating engine to 4.15.1 “using same blueprint as before” when i pickup the pistol it doesnt assign the ammo rightaway" works as intended.
When i pickup the Ammopickup on the ground , it correctly assigns the ammount of ammo specified “works as intended”
but when i unequip and reequip the pistol , it deletes all the stored ammo