How do I get an ammo system to work?

0 favourites
  • 5 posts
From the Asset Store
_______ Huge collection of metal fixtures ________
  • I'm building an ammo system in a game. Basically I have 3 guns, pistol, minigun, and rifle. The pistol is single fire, the other two are automatic. I have a global variable set to 0, for ammo, and an item to pick up which adds to that variable. I also have systems where if ammo is below zero, the gun doesnt spawn a bullet.

    It's fairly simple but refuses to work. I set a text box to the ammo variable, to track it and see if it was counting right. I walk over the pickup item, and boom, nothing is added to the text number. This might just be an issue with text boxes.

    The automatic guns use "Left Mouse is down" to register their automatic fire. I made a thing that corresponds, with "Left button is down", and subtracts from the "Ammo" variable every second. But for some reason, the automatic guns ignore the ammo count entirely and fire regardless. This makes no sense. I have parameters in place where if "Bullet on created, if Ammo = 0, destroy Ammo". This means that the bullet shouldnt be firing if the Ammo variable is zero, regardless of what gun. I'm utterly lost and cannot comprehend how this isn't working. Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Can't resolve without the capx, or a screenshot of the events could potentially be good enough here, share that and it can be resolved straight away.

  • https://drive.google.com/file/d/1ZWT-xQ ... sp=sharing

    This google drive should work?

  • Text box needs to be every tick to update the value of the global variable constantly. On created just shows the global var value at the start of layout when text box is created. The ammo value was always correct though, I checked in debug mode.

    The problem with the guns appears to be that the bullets are firing every tick so fast that when they are fired, ammo is less than 0 in that tick before fixed by event 79, so the ammo=0 (event 80) isn't true at the point the bullet is created. What is happening is that ammo is always less than 0 whenever a bullet is fired on those guns. Change event 80 to less than or equal to 0 and it's fixed.

  • Never would of got that in a million years, thanks a ton!

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