How to make a working cooldown function

0 favourites
  • 10 posts
From the Asset Store
_______ Huge collection of metal fixtures ________
  • I'm trying to make a cooldown function that sets my game on pause for 5 seconds.

    I have a function that I call in the code with a sub event saying "Every X seconds" which I have set to 1 to fire it every second. But somehow the timer is running only once. Any ideas what might be wrong?

    Edit. Updated with screenshoot

  • You said you are settings something to 1 every X seconds, but are you settings it back to 0 after that?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You said you are settings something to 1 every X seconds, but are you settings it back to 0 after that?

    I have updated with a screenshot.

  • Your every x seconds is a sub event of a triggered event, which only fires once every time the function is called.

    (On function only lasts for one tick)

  • Your every x seconds is a sub event of a triggered event, which only fires once every time the function is called.

    (On function only lasts for one tick)

    That was what I suspected. Any ideas how I could make this work?

  • That 's too complicated.

    Just use an Instance variable + TIMER.

    Example: Instance Var: ATTACK1

    On [Attack] | Set ATTACK1 to 1

    . | Start Timer

    On Timer | Set ATTACK1 to 0

    Disable attack when ATTACK1 is 1.

  • That 's too complicated.

    Just use an Instance variable + TIMER.

    Example: Instance Var: ATTACK1

    On [Attack] | Set ATTACK1 to 1

    . | Start Timer

    On Timer | Set ATTACK1 to 0

    Disable attack when ATTACK1 is 1.

    Well, it not for an instance, but for the whole game. Several objects will be hidden.

  • Well, it not for an instance, but for the whole game. Several objects will be hidden.

    Same concept. Use Global Variable instead.

    Global Variable: PAUSED = 0

    Create a random sprite, a small pink box(or any color you want) that's set invisible that serves only as a timer holder.

    On PAUSED = 0 | [EVERYTHING in your game]

    On [Paused Button] pressed | Set PAUSE to 1, Start Timer...

    You get the picture.

  • Use a GAMESTATE global variable - 0 is normal, 1 is pause. Have your trigger function set GAMESTATE to 1

    Have a separate counter event.

    If GAMESTATE is 1

    Every X seconds - Do Countdown

    -- Cooldown < 1 - Set GAMESTATE 0

    Edit: Didn't see mpplant already replied. Yeah basically what he said

  • Yeah, worked fine!

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