Ammo
Ayolabi12345
Member Posts: 30
My game includes shooting. Its a platformer. How do I add an ammo limit and gauge
My game includes shooting. Its a platformer. How do I add an ammo limit and gauge
Comments
I really think you need to do some research before you post a million questions on the forum.
I suppose
I have reason to believe u are exaggerating by 999,995
Haha maybe a little bit. But seriously download some templates watch some video tutorials search the forum there's heaps of ways to find out what u need to know and most the time it is quicker aswell.
Indeed watching some tutorials would help, but to answer your question, you'd be best of setting an integer attribute, setting it to decrease by 1 every time a gun is fired, and one of the rules of firing is the ammo attribute =<1, these are pretty basic things.
So, not sure what you mean by gauge, but @WOLFENSTEIN is right, you want to create an attribute... probably game attribute called say... ammo.
Before you spawn the bullet, you do a conditional... if the ammo count is greater than 0, then spawn the bullet and reduce the ammo to 0, otherwise do nothing or play a empty magazine sound.
If you want multiple types of bullets and ammo counters for each, that gets more complex...
You would need a gauge attribute... say 1 = .22 bullet, 2 = .32 bullet, 3 = 9mm and 4 = .45 bullet. You would also need 4 ammo attributes, ammo1, ammo2, ammo3 and ammo 4 to track the 4 different types of ammo.
Depending on which gun they were using, you would set the gauge attribute to 1 through 4. Say they start with the .22, then you would make gauge = 1.
In your fire routine, you'd have a conditional to check for gauge. If it equals 1, then you do the same as above, only if they have ammo left, you'd spawn the .22 actor (maybe a really small bullet) and deduct 1 from ammo1.
If they run out of .22 ammo and switch to the 9mm, then gauge would be set to 3 and you'd have another conditional for gauge = 3 that deducted 1 from ammo3 and spawned the 9mm actor.
Make sense?
Yes thanks guys
@Ayolabi12345 - I've created a sample project for you to look at, if you're interested. It has 4 bullet types and 4 different ammo counters.
Clicking on the ammo types at the top of the screen will switch to that "gun" and space bar will shoot, decreasing the ammo with each shot. If there is no ammo, no shot is fired.
You can also walk around with A & D keys.
https://dropbox.com/s/i2k9aw6mgvzkir5/Ammo%20Demo.zip?dl=0