After you Shoot,you get a Cooldown.

Get help using Construct 2

Post » Wed Apr 09, 2014 6:29 pm

Hello,
I want to make that if i Shoot with Left Mouse. After that you can't Shoot for some Seconds. I tried this. Mouse/Left Mouse pressed = Spawn a Bullet and than Wait. But it don't work with Wait. How i can solve that ?
B
7
Posts: 61
Reputation: 393

Post » Wed Apr 09, 2014 6:49 pm

You can create a variable, for example "Shot" and make it so you can only shoot if this variable value is zero, so, when you shoot set the value to 1, and after X seconds set its value to 0 again.
B
37
S
5
G
2
Posts: 46
Reputation: 3,854

Post » Wed Apr 09, 2014 6:49 pm

I would use a boolean and set it to true. When you shoot with the left mouse button, set that bool variable to false. That way, no matter how often someone clicks that left button it won't shoot. Then, after the Wait period you've set is up, set the bool variable back to true. Now they're able to shoot again.
B
7
S
1
G
1
Posts: 56
Reputation: 732

Post » Wed Apr 09, 2014 6:59 pm

You need to make a distinction between Conditions and action.
The cooldown is part of the condition not an action, so you should not use the Wait action.

There are 2 ways to make the cooldown.
First method is using instance variable.
Add Instance Variable to the player, lets call it PlayerCooldown. Its value should be zero on default.
The player can shoot if the PlayerCooldown < 0 and lmb is pressed.
When he shoot, the PlayerCooldown value will be set to Value X (in seconds)

Make another event that will reduce the PlayerCooldown value to zero. An event condition like Every X seconds can do the job, Make it so Every X seconds, X value of PLayercooldown will be substracted.

Method 2, make use of an add-on created by rexrainbow
viewtopic.php?t=64408&start=0
It's time for me to return the favor :)
B
32
S
9
G
9
Posts: 132
Reputation: 5,370

Post » Wed Apr 09, 2014 8:26 pm

punkineo wrote:I would use a boolean and set it to true. When you shoot with the left mouse button, set that bool variable to false. That way, no matter how often someone clicks that left button it won't shoot. Then, after the Wait period you've set is up, set the bool variable back to true. Now they're able to shoot again.


Wow thank you very much :)
And again the Solution was Boolean,i never think about it ...
B
7
Posts: 61
Reputation: 393


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, JackTYGA, Kin, worm1 and 30 guests