Download

Ammo system for line trace

Hello, I need help with an ammo system for my game. I know how to make an ammo system when i spawn the bullets but I´m using the “weapon trace” and I dont know how to do that. If it helps I´ve attached a picture below.

Thanks in advance^^

So what’s stopping you from counting the bullets when you fire this? Assuming that’s what you refer to when you say ammo system.

Pull a trigger, reduce the bullet count:

Perhaps you could explain why this wouldn’t work?

1 Like

Hey thanks for the quick answer,
It doesn’t work for me because it does not decrease the number of bullets, it just decrease the number of times I can “shoot” press. So it It doesn’t continuously reduce the number of bullets

How is this supposed to be working then? You press the button and auto-fire? And clip gets emptied? We know absolutely nothing about your system…

Oh, sorry I will add another picture…

Weapon trace is my first picture at the top of this forum post


Sorry mate, but I do not understand what is stopping you from counting down bullets left. You have a looping function, keep track of ammo left, if there’s no more ammo, prevent the player from firing.

1 Like

Where could I start reducing the bullets?

Where could I start reducing the bullets?

When the function attempts to fire.


The entire system could look like this.

From the top:

  • check if there are bullets left when you start firing, no bullets == no firing
  • if there are bullets left, start firing; every time you fire, remove a bullet
  • as you fire, keep checking if there are bullets left
  • if there are none left, we stop firing
1 Like

Oh my is a little bit different :smiley: I will put your blueprint after Input Fire Weapon

Hey,
Do you know where I might get stuck? I´ve recreated this, but the player still shoots endlessly.

Is Firerate > 0? is Ammo > 0?

Also:

image

Use the Debug Filter for that blueprint, this way you can observe how the data flows while you play:

Right click pins to Watch this Values to see whether things add up:

image

And put Print String everywhere.

Hey, I´ve tried what you wrote and I found out that it stops at “CustomEvent0”

Are the variables I mentioned > 0? What does it mean that it stops at it? It’s a delegate - does the event fire?

You’re supposed to hold the button for this to work, btw. If you release, the repeater will stop, ofc.

No sorry, It stops at the print string after the next branch the true output doesent fire. And if I hold the fire button it fires just one time, but if i click the fire button(I can click it 30 times like my ammo) the hello world string fire every click… so my weapon isnt full automatic anymore…

My Blueprint right now is:

Could you please confirm what the weapon firerate is set to - I’ve now asked 3 times… :slight_smile:

Oh sorry my Weapon Fire Rate is 0,08(Float)

Yeah… crank it up. We’re dividing here.

Here, that value dictates how many times per second you shoot. So if you set it to 10 (like in my pic - have a look at comments) it will shoot 10 times per second.

1 / 0.08 = 12.5. So you were shooting auto but every 12.5s.

So I just need to change my Firerate to 10?
Ohhh now I Understand :smiley: :smile:

1 Like

Set it to the number of bullets you want to discharge per second. That should be it! fingers crossed

1 Like