[SOLVED] How to create ammo system?
THE D3TH KNIGHT
Member Posts: 5
I have created an ammo system, just didn't want the title to be so long. How do I make it so when the attribute "Ammo" is equal to or less than zero I can't shoot? I could have negitive ammo and still be able to shoot. Here's what it looks like:
And this is what I put:
If anyone could help that would be great
Best Answer
-
natzuur Posts: 304
@THE D3TH KNIGHT said:
For shooting I used the "Spawn Actor" Behavior. Everytime the ammo goes below 1 it shoots or "spawns" a bullet. I can continue to use the mouse button to shootYou'll want to restrict both the ammo and the shoot rule.
when actor receives event mouse button is down when attribute ammo is greater than 0 change attribute ammo to ammo-1 spawn actor bullet. when ammo is <= 0 for 4 seconds constrain ammo to 0 after 4 seconds (run to completion) Change ammo to 16
Answers
So the 16 is a reload? In that case put a timer in the rule for ammo
for 4 seconds constrain ammo to 0, after 4 seconds (run to completion) change ammo to 16.
if you want to restrict shooting you say when ammo > 0 and touch is pressed, shoot or change ammo or however you have it set up.
Ok, the ammo now stays at zero, but I still can't figure out how to restrict shooting when the ammo is zero. The last part was a bit unclear to me
This is what I have now:
If you want to restrict shooting, on the shooting rule, add a rule that says when ammo > 0, and touch is pressed (or however you have it configured) shoot (or whatever variable/logic you have for triggering the shot).
In this setup if ammo is ever 0, you cannot shoot, only when ammo is greater than 0.
So you're saying if ammo is = or < 0 and the mouse button is pressed I make it shoot? Wouldn't that shoot the bullet instead of restrict it? I tried it but it just shot
No. Use either:
when ammo is >=1. or
when ammo is >0
Shoot
For shooting I used the "Spawn Actor" Behavior. Everytime the ammo goes below 1 it shoots or "spawns" a bullet. I can continue to use the mouse button to shoot
Finally! Thank you.