Setting Up Ammo System | Unreal Engine Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everybody I'm gonna show you how we can Implement an ammo system on the default uh first person shooter template on Unreal Engine so first things first you're going to want to open your character blueprint so head over here first person character double click so I've already cleaned this up if this looks a little different than your uh first person character blueprint I've just deleted some of these uh useless nodes that are only for VR so if you want to clean it up just copy how mine looks I haven't added anything yet I've just deleted some of those extra nodes um okay so first things first we're going to want to add a new variable so let's head over here click the plus variable and let's name this ammo right so or actually okay let's name this current ammo and then let's change the variable the variable type into an integer so this integer it will basically we're going to use this to keep track of how much ammo we have left in the gun so we're going to want to click this copy paste it and then let's make another one called max ammo so I think all right let's begin with let's say six ammo is our starting uh max ammo all right so first things first we're going to want to put a branch we're going to want to add a branch over here and plug in this uh pressed node into the branch and then we go true continue on so the condition that we're going to give is is our current ammo greater than zero if it is then continue on us so we shoot as normal but if it is not then we're going to want to print string and call this uh no we're gonna we're gonna wanna know that our code is working correctly and we want it to tell us that there's no ammo left so all right so this is basically base code that we haven't changed but we do have to add something here so every time we do fire off this uh projectile we're going to want to set our current ammo and we're going to set it to current ammo minus minus and what this is minus minus is basically taking whatever current ammo is and reducing it by one and then we're going to set current ammo to whatever that is so uh all right let's print screen print string two just so we could see how much ammo is left every time we shoot and let's try if this works all right so let's hit play and see if this works so you can see on the top left corner there it says five shoot again it should say four three two one zero now if I click no ammo no ammo no ammo so you can see that our ammo system is working um so let's quickly add a reloading uh section here so let's make a custom event for reloading let's custom event let's call it reloading or let's call it reload all right so when we reload uh what we're going to want to do is uh let's put a delay let's say it takes two seconds to reload uh all right actually let's do all right so when we reload we're going to want to set our current ammo to our max ammo mm-hmm so let's delete this print string and let's call it the reload function right here so let's hit play see if that works five four three two one zero and then if I click again now we go back to five four three two one zero all right everything seems to be working uh uh okay let's say we want to put a delay in the reloading so let's say two seconds yep uh but we're going to want to limit this right we're going to want to do once because we don't want to be reloading at a delay over and over again so let's do reload um and then to reset our reload we want to make sure that we have fired first so let's put this and plug this and reset compile and Save and actually let's add a little uh print string at the end of this so that we know once it's done reloading let's put done reloading compile save hit play five four three two one zero and then if I click again nothing happens two seconds done reloading and I should be able to shoot again five four three two one zero click again nothing happens and then we get the done reloading at the top left and then five four three two one zero all right uh if you found this video helpful um please leave a like uh so that other people can find this video and if you want to support us please head over to our Play Store page where we upload all our games for free go ahead and play some of them go ahead and try some of them and we would appreciate it greatly if you left a review and a five star rating thank you so much peace
Info
Channel: Studio Bit Byte Games
Views: 5,478
Rating: undefined out of 5
Keywords:
Id: AHUV3TioUXo
Channel Id: undefined
Length: 6min 16sec (376 seconds)
Published: Tue Dec 13 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.