Issues with pausing my game and timers/object timescale

0 favourites
  • 3 posts
From the Asset Store
Tabata timer
$9.99 USD
Template for Tabata timer, fully documented in comments and video
  • To pause the game I have a family of objects that I pause the timescale of. The reason I don't set the game's timescale to 0 is because I wouldn't be able to navigate the menu properly with arrow keys since the game would be frozen. But I run into an unfortunate problem as a result of this method... 'Every X Second' events continue since they're system events, not object events...

    If the mouse is held down, every 2 seconds the player will spawn a bullet. It works fine until I pause! It won't continue shooting bullets during pause, but the 'Every X Second' event will continue counting down - thus the player will shoot the moment you unpause as long as your mouse button is held down. This is incredibly game-breaking because it allows the player to shoot more bullets than they should..

    So for example, if the player spawns a bullet, the system will start the 'Every 2 seconds' event and start counting down. The next bullet shouldn't spawn until 2 seconds later. But when you pause, the game still counts down... If you wait 2 seconds, you'll be able to unpause and shoot again immediately.

    I tried to get around this by using timers... Since timers are an object behavior, if the object's timescale is set to 0, the timer will pause as well.

    If the mouse is held down, on Timer (DPS) finished, spawn bullet. ... Since the timer only has an 'on timer finished' event, the player is required to have their mouse down during the time the timer finishes in order to spawn another bullet. If the Timer finishes and the player doesn't have their mouse button held down, you can never spawn a bullet ever again, so this method won't work.

    Does anyone have a work-around? To be clear, I don't want to set the game's timescale to 0 because that freezes the menu, making it unsuable.

    Thanks in advance!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Set the global time scale to 0.

    then give one of the menu objects their own timescale.

    And use this object's timescale for anything you want moving in the menu.

    I'm not sure if that's the official way to do it , but it is they way I have done it and it works fine.

  • Set the global time scale to 0.

    then give one of the menu objects their own timescale.

    And use this object's timescale for anything you want moving in the menu.

    I'm not sure if that's the official way to do it , but it is they way I have done it and it works fine.

    Genius. I was thinking about it backwards the whole time, thank you so much. This method will stick with me forever

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