How do I create ability cooldown?

Get help using Construct 2

Post » Thu Sep 10, 2015 6:58 pm

Hi, im trying to make cooldowns for abilities. When 'player sprite' spawns 'bullet object' id like to wait until the bullet is destroyed to spawn another.

Ive tried doing it with a 'cooldown' variable but it seems to have no effect. This is what i have,

On right click / if 'cooldown' = 0 > create 'bullet object'

On 'bullet object' Created > set 'cooldown' to 1

On 'bullet object' Destroyed > set 'cooldown' to 0

On bullet distance traveled >600 > Destroy 'bullet object'


Ive tried a few variations of this. Sometimes it has no effect, other times you can just spawn 1 then no more after that. Any ideas would be appreciated ty.
B
9
S
3
Posts: 104
Reputation: 1,033

Post » Thu Sep 10, 2015 7:43 pm

Wouldn't it be better to shoot in an interval, with the help of the timer behavior.


on right click:
create bullet
start timer "gunfire" regular for cooldown seconds

on right mouse button released:
stop timer "gunfire"

on timer "gunfire"
create bullet


With the cooldown variable you could change, how much time it takes between shoots. Distance traveled seems like a weird choice to me in most situations. If the bullet flies at constant speed, you can calculate the time it takes to travel 600 anyway.

Problem with your event is: on right click only triggers once, when you press the button, not when you hold it down.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Thu Sep 10, 2015 8:03 pm

Thanks for the tip, ill give it a go.
B
9
S
3
Posts: 104
Reputation: 1,033


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 4 guests