Hello. How do I make ammo show subtraction?

0 favourites
  • 9 posts
  • Hi guys, I'm new to Construct3 and am having trouble showing the ammo being subtracted from the textbox everytime I shoot.

    The amount of ammo shows okay and that amount is shot okay too. It's just the ammo number remains the same.

    Could somebody here show me a detailed example of how I can do it, please? Thanks so much!

    Tagged:

  • Set Text to global variable ammo every time you shoot. Did you just set it once on start of layout?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have global variable for Ammo at the beginning of the events page only.

  • What problem are you having? You said it shows okay but then it doesn't? You need to update the text in the text object each time.

  • What I'm trying to do are these events:

    Collect bullets

    Show 10 bullets on textbox (not limited to 10)

    Every time spacebar is pressed once, fire 1 bullet from inventory and subtract 1 from textbox.

    Is there an example I can study or copy that anyone has?

  • You just need to set the text to show the global variable. As the variable changes it will update on the text.

  • Okay, this is what I have done so far and what the result is...

    Set a global number for bullets.

    Player on collision with bullets gains 10 bullets to fire on spacebar pressed.

    System: Bullet greater or equal to 0

    Every tick deducts 1 bullet from player's bullets of 10 (problem is the count on textbox goes down to 9 bullets after pressing spacebar twice instead of what should be once. Every shoot after is one bullet as I want it to be from the start).

    If I collect more bullets, total will not go above 10 bullets on textbox and player can not shoot more than that either. I don't want an upper limit. I want only what player collects.

  • In debug preview you can see if the variable is as expected. Setting the text to show the variable is different, you can set an event every tick > set text to variable then it will be correctly showing the variable.

  • Can't see the debug preview on free version.

    I just can't get it to work properly. I'll keep looking for a video that shows a working example. Seems like 99% just use basic unlimited ammo though.

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