1
$\begingroup$

I made a weapon that shoots projectiles in blender. Whenever the user holds down the fire button, the weapon shoots projectiles at the rate I want it to shoot. However, when the user hits the fire button rapidly, they can shoot as many projectiles as they want depending on how fast they press it.

How can I make the gun shoot at the same rate, regardless of wether the user spams the fire button or not.

$\endgroup$
2
  • 3
    $\begingroup$ For future reference it would help if you'd include some screenshots or even a blendfile for testing purposes. $\endgroup$ – Delagone Nov 22 '16 at 9:09
  • $\begingroup$ Just use a timer and say that you can't shoot until the timer is up. This could be achieved by toggling the value of a game property. $\endgroup$ – christai Feb 8 '17 at 2:51
1
$\begingroup$

This method explains how to achieve this result using only logic bricks.

  1. First enable TRUE level triggering.
  2. Then assign the number of ticks it requires before proceeding to the next action.

This should easily work in your case.

enter image description here

$\endgroup$
1
$\begingroup$

Better toggle between a "ready to fire" and a "reloading projectile" state.

This way the player will not be able to fire faster by fast releasing.

When ready the weapon can fire the projectile on request. At the same time it will start reloading a projectile (semi-automatic weapon).

enter image description here

When reloading a projectile we just wait a certain time (as it is not a real weapon). Here you could for example count the available bullets.

enter image description here

How does that work?

  1. It starts with state "ready". That means the weapon is loaded and ready to fire.

    • When the player request fire (by pressing a button) the projectile gets added (fired) and the weapon switches to reloading state.
  2. Within state "reloading projectile" any fire request will get ignored.

    • When loading is done, the weapon switched to "ready".

The player can fire again.

A) The above setting let the weapon work in "full automatic mode". This means when the player still holds the fire button, the next "fire" will be executed. To get a semi-automatic fire mode, you can disable the [Level] parameter. This means the user has to release the button and press it again.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.