I'm doing the 'Cooldown' WRONG! (help?)

0 favourites
  • 4 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hello All,

    As I keep progressing working on my very first game on C3... I'm experimenting things.

    on my actual game things are much more complex even for me to follow, so I re-create a minimalistic .capx with almost the same idea.

    In my actual game-project I uses functions and animation priority so it's not exactly the same, I still want to see if I can re-create the solution on my game-project.

    Cooldown:

    My first attention was to make a Timer for the Cooldown, with no variables or anything but when I tried to do so I got confused and I tried a different approach which is "almost" working but not really.

    I describe on the attached .capx how to create the BUG, but I'll explain it also in here in case you didn't download it yet. the Debug-Mode shows the issue as well.

    The Bug:

    If on the start of the level you'll press 'C' many times as fast as you can,

    it will spawn more than 1 splash attack, that's the bug.

    My goal is to limit attack to: only one per X time.

    (probably less than a second but I will be able to change it).

    Thanks ahead for any alternative stable solution.

    Download .capx file HERE !

  • See image.

    Use a cooldown timer and count down per tick (subtract the cooldown timer by `dt` -- delta time). Only when cooldown timer is <=0 can the player attack.

    In the image above I did not cap the cooldown_timer to 0, so it will keep on counting down. You should put something like, if cooldown_timer < 0, then cooldown_timer=0.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • See image.

    Use a cooldown timer and count down per tick (subtract the cooldown timer by `dt` -- delta time). Only when cooldown timer is <=0 can the player attack.

    In the image above I did not cap the cooldown_timer to 0, so it will keep on counting down. You should put something like, if cooldown_timer < 0, then cooldown_timer=0.

    Thank you for the image and explanation, I will try to follow and do this.

    For matter of my organization: Can I use an Instance Variable on the Player like rest of the variables?

    or I must use a local variable like you did? I'm not sure if it matters or not as I'm still learning.

    to be honest I don't understand everything yet but maybe after I'll try to build it following your image it will make more sense to me.

  • Generally speaking, you should use instance variables if it relates particularly to the instance. In the case of `cooldown_time`, this seems best to be put in an instance variable of the player since other NPCs/enemies may have a different `cooldown_time`. Or maybe the player, in future 'levels' may improve their rate of attack separate from other entities.

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