Hello everyone, I am creating an action game in which the player can shoot by left-clicking the mouse. Only, I ha spams the left mouse button the game becomes too easy.
Is there a way to prevent the player from shooting repeatedly ?
Develop games in your browser. Powerful, performant & highly capable.
You'll want to set a timer variable.
Something like this:
on left click:
if timer > 0.5:
--> shoot bullet
--> set timer to 0
every tick:
--> add dt to timer
You can change the '0.5' to change the possible rate of fire. You can also change 'on left click' to 'left button down' to allow them to hold the mouse button down to keep firing.
Thanks Sqiddster for awnsering this fast !