Flipping Gravity

0 favourites
  • 4 posts
From the Asset Store
Gravity Square is a game where I aim to reach the square at the polka dot door :)
  • I am trying to do gravity flipping when pressing space. I created a variable called FlipGracity and gave it value 0 or 1. 0 will make the player fall down and 1 fall up. I can only make the character fall up when pressing space. However when i copy the event again and change the variable, the character couldn't fall up or down.

    It only works if i use different keys, like space for falling up and z for falling down.

    Could someone please take a look on my capx file? thanks!

    dropbox.com/s/3v4roo7owlb9mf1/FlippingGravity.capx

  • Hey nicklowkcmagic,

    it did not work because it is first checked whether your variable is 0 to set it to 1 and after that it is checked whether your variable is 1 to set it to 0. So the variable is 1 for one tick. Try it with 'else':

    + Keyboard: On Space pressed
    
    ----+ Player: FlipGravity = 0
    -----> Player: Set FlipGravity to 1
    
    ----+ System: Else
    -----> Player: Set FlipGravity to 0
    [/code:dabf8hbx]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here is how you can do this in one action:

    Set FlipGravity to (FlipGravity=0)

  • nicklowkcmagic

    set the instance variable to 1 or -1, depends of which direction you want at start. Then change your code to:

    Player | FlipGravity=1 -> Player| SetPlatform gravity to 1500
    Player | FlipGravity=-1 -> Player| SetPlatform gravity to -1500
    
    Keyboard | On space pressed -> Player | Set FlipGravity Player.FlipGravity *-1
    
    [/code:1555fvp9]
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)