Make the same Key both Pause and Unpause the game.

0 favourites
  • 10 posts
From the Asset Store
Random Maze Generator with Door & Key System - tutorial capx
  • So far this piece of code works great:

    Key Press Condition > Set Timescale to 0 Action

    How do you make it so the same key press pauses the game, and unpauses the game.

    Key Press B > Set Timescale to 0

    Is it possible to also make Key Press B > Set Timescale to 1.0

    So B both pauses the game, and while the game is paused, pressing it again unpauses the game (as in, the same key that sets the Timescale to 0 also sets the Timescale to 1.0 when the Timescale is 0 )

  • Press Key > Set Timescale to 0 works perfectly, and I don't want to mess with that.

    Now, the issue is making it so the Key that when pressed sets the Timescale to 0 is the same key that when pressed, sets the Timescale to 1.0 WHILE the Timescale is 0.

    Timescale is currently 1.0

    Press B

    Timescale is now 0

    Press B

    Timescale is now 1.0

  • ,

    just put a condition checking the current timescale and changing it accordingly...

    press B

    if timescale == 0 then timescale := 1.0

    else

    timescale := 0

    that should do it.

  • You could even put it into a single expression like

    set timescale: timescale = 0?1:0

  • You could even put it into a single expression like

    set timescale: timescale = 0?1:0

    Or set timescale = 1-timescale

  • I cannot find the If statement and Else statement. I checked under System and it's not there.

    I am looking here: but it has no mention of where in System If, Else, and Then are. I created a New Event, and searched for If, Else, and Then, but those 3 things were not there.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I cannot find the If statement and Else statement. I checked under System and it's not there.

    There are the "system compare variable" and the "system compare two values"

    The system else condition is there, but only if it's possible at that spot..

    Another way to get to the else statement is through the right-mouse-button-dialog

  • I am just not getting this. I am trying to duplicate this:

    press B

    if timescale == 0 then timescale := 1.0

    else

    timescale := 0

    Press B is the event. If Timescale is the action, but compare variable is not available under actions.

    Press B is the event, and the if else and then are the actions, but compare variable is not availble under actions.

  • Omygosh thank you so so so much everyone! That worked like magic. I understand the sub-events now. When i first saw sub-events i thought "What, like the Metro system?" (ahaha, not really. But i really did not understand them.)

    Thank you again!

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