Several bullets fired when left mouse button is pressed once

If, as for me, when you trigger the left mouse button several bullets are fired, you can add a “Delay Node” before the Spawn Emitter. :wink:

That’s because triggered isn’t a single click think, as I pressed the released events.

What you could do is use a bool for when it is pressed and on release, clear it again and do a check at the start.

This wasn’t an issue with the old action system and is kind of unique to the new input system

Thank’s for your comment but the delay node works fine and so you don’t have to declare a new variable which is better in the C++ way.

Even with a delay, holding the button down continues to fire, no? It would be a slower rate than clicking. As it happens, this may be a desired side effect.

As it is a “sub-machine gun” it’s effectively what I wanted. But for any other rifle, you’re absolutely right.

1 Like

You may be able to set the frequency of the trigger in the enhanced input. This would be a better solution. Worth looking anyway.

I looked further about EnhancedInputAction and, in fact, if you want only a one shot action, you must use “Started” instead of “Triggered”.
Than you for inciting me to look further…

1 Like

I knew there was a way! I’ve only briefly looked at UE5

1 Like

I’m kind of late to the party but if you’re using the new Enhanced Input System, the way to do this is kind of different.

Your input action, IA_Fire, can have modifiers. Hopefully, whoever reads this can see the image. One modifier could be Pressed. Pressed shoots once, that’s it. If you also want to be able to shoot continuously, you can add another modifier, Hold. Hold will need a Hold Time Threshhold of like 0.1 or 0.2.

If you do what is explained above, if you press and release right after, you’ll shoot once. If you hold for the Hold Time Threshhold, after shooting once, it will start continuous shooting.

So, if you’re using the New Enhanced Input System, you can avoid using delays/variables and stuff like that on the event graph. However, if your gun fires as fast as mine does, you may still want to use a delay, which can be paired with Pressed and Hold.

1 Like

Privacy & Terms