[SOLVED] How to create ammo system?

THE D3TH KNIGHTTHE D3TH KNIGHT Member Posts: 5
edited June 2014 in Working with GS (Mac)

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

  • natzuurnatzuur Posts: 304
    edited June 2014 Accepted Answer

    @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 shoot

    You'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

  • natzuurnatzuur Member Posts: 304

    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.

  • THE D3TH KNIGHTTHE D3TH KNIGHT Member Posts: 5
    edited June 2014

    @natzuur said:
    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:

  • natzuurnatzuur Member Posts: 304

    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.

  • THE D3TH KNIGHTTHE D3TH KNIGHT Member Posts: 5
    edited June 2014

    @natzuur said:
    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

  • natzuurnatzuur Member Posts: 304
    edited June 2014

    No. Use either:

    when ammo is >=1. or
    when ammo is >0

    Shoot

  • THE D3TH KNIGHTTHE D3TH KNIGHT Member Posts: 5

    @natzuur said:
    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

  • THE D3TH KNIGHTTHE D3TH KNIGHT Member Posts: 5
    edited June 2014

    @natzuur said:
    A bunch of stuff (Best Answer)

    Finally! Thank you.

Sign In or Register to comment.