How do I limit fire rate?

Just started using Construct 2? Post your questions here

Post » Sun Nov 02, 2014 1:07 pm

I'm trying to limit the rate at which the player can fire to once every second and at the moment I'm simply setting a variable called Firing to 1 when the mouse button is clicked then back to 0 after one second and adding the condition that Firing must be set to 0 in order to fire. The problem is that you can often 'beat' this system by clicking the mouse really quickly, presumably because of the slight delay in changing the variable. What's the simplest way for me to ensure the limit on fire rate is absolute?

Thanks in advance!
B
5
S
2
Posts: 53
Reputation: 792

Post » Sun Nov 02, 2014 4:07 pm

That's weird, it should not happen, cause I am sure no matter how fast we manually rapid press the button, the code will still run faster.

Perhaps you can upload a screenshot for us to take a look at those events.
B
42
S
20
G
31
Posts: 685
Reputation: 20,221

Post » Sun Nov 02, 2014 4:22 pm

one solution might be -> is in touch -> system every x seconds * firerate -> spawn playerbullet


regards
B
19
S
7
G
1
Posts: 222
Reputation: 2,546

Post » Sun Nov 02, 2014 7:52 pm

Thanks very much to you both - I will try that suggestion right away and in the meantime here is a screenshot of my current system. The subevent was just me trying a workaround - I had exactly the same problem when combining all into one event and losing the 'trigger once.'

scirraforums.png
You do not have the required permissions to view the files attached to this post.
B
5
S
2
Posts: 53
Reputation: 792

Post » Sun Nov 02, 2014 7:58 pm

j0schi's technique worked perfectly. Thank you!

I'd still be interested to hear any insights into why mine failed though.
B
5
S
2
Posts: 53
Reputation: 792

Post » Mon Nov 03, 2014 1:24 am

You don't need variables if you want just one shoot every x seconds.

mouse click
every x seconds ------------------- shoot
Image
B
60
S
10
G
10
Posts: 1,013
Reputation: 9,155

Post » Mon Nov 03, 2014 6:55 am

A0Nasser is right, but you might want to keep this for later modifyers :)
B
19
S
7
G
1
Posts: 222
Reputation: 2,546

Post » Fri Nov 14, 2014 4:25 pm

Hi!
I dont understand T_T
Can you show project file (about rate of fire)?
Tnx u.
B
4
Posts: 1
Reputation: 202


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests