How do I create ability cooldown?

0 favourites
  • 3 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • Thanks for the tip, ill give it a go.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)