How do I make a limit on how many bullets my char can shoot?

0 favourites
  • 14 posts
From the Asset Store
Ninja char for your game! Make your own Shinobi game with this art.
  • Hello all, I have a question; how do I make a limit on how many bullets my character can shoot? Right now my main character can shoot an infinite amount of bullets. I want to limit this, can somebody point me in the direction of a good tutorial (please)?

    Thanks,

    guannstar (FNORD)

  • Hey! Do you mean so that there's an amount of time between shots or there is a limit on the quantity fired?

    Basically do you mean a reload time or ammo?

  • No, not reload time, I'm talking about having to use/pick up ammo. (Thanks for the quick reply.)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • No problem! Using an instance variable is probably best. Give your character a variable "ammo" and set it to 10 or something

    On the shooting event add another condition - character, compare instance variable, ammo > 0

    Then add an action - character, subtract from, subtract one from ammo

    If you need to pick up ammo, just add to the ammo variable.

    Hope this helps!

  • OK, thanks a lot, I'll try that and get back to you:)

  • Yeah, that did help a lot. Just one more thing thing though, how do I display text that says how many bullets I have left? Do you have to link a text variable with a number variable? If so, how?

  • Bump:( Sorry, but I really need some help.

  • You have the text box object option you can display it or spritefont. There have been a few issues that text box wasn't working on all browsers and stuff so it is recommended to use spritefont. But for testing a rextbox should be fine all you have to do is set the event that says text box set text and put the variable that you are using to be placed there.

  • I believe the Text object is what you want and not the Textbox !

    https://www.scirra.com/manual/116/text

  • OK, I did everything LevelUpJordan said, there's still one problem though. In the image below, there is "Text" under the "S" button (which is the shooting button). When I preview the game everything works fine. My character has a limit now of 36 shots. When they are done (the bullets), he has to pick up an item to get 18 more bullets. That's exactly how I wanted it, so thanks for that:) The problem is that the "Text" below the shooting button below shows up when previewed as the number 36, but does not subtract anything from itself at all when I shoot. Can somebody help to explain why that might be?

    P.S. The Text below the shooting button was named "AmmoTxt".

    Thanks,

    guannstar

  • Bump, sorry:( I really need some help.

  • I literally just did this do

    system -> on every 0.1 seconds

    action: set text to "varAmmo: " & varAmmo

    the varAmmo after the & should be the global variable you have set.

    I believe this is how i did it, not 100% sure though. I don't have access to look at exactly what I did, but will double check later tonight and respond back if thats wrong. Let me know

  • I did a zombie top down game test a while ago... it's old, but have the limited bullets thing <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    take a look!

    https://dl.dropboxusercontent.com/u/191 ... este2.capx

    in the events tab, go to "armas" group and then "p220".

    any questions, just ask;

  • Actually robertjs3, don't worry about it... thanks though. Also, thanks a lot to everyone else that helped me out with this problem. I just now figured out how to fix it:)

    Thanks again,

    guannstar (FNORD)

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)