Jump & Double Jump

flapairflapair Member Posts: 67
edited January 2012 in Working with GS (Mac)
So hey everyone,
I'm making a really cool game with the style of Runaway Pengy and i was trying to make him jump just like the game. So i could make the actor jump but i don't know a way of making him double jump with a button. So i wanted to know if anyone could teach me how to make a double jump by clicking a button 2 times and when clicks 1 time just do a normal jump.

Could anyone help?

Thanks,
Flap Air

Comments

  • AsymptoteellAsymptoteell Member Posts: 1,362
    Put all this in the jumping actor:

    Accelerate downward at however much you want for gravity.

    Make a new self attribute in the jumping actor. Call it jump #

    Then when overlaps or touches floor actor,
    Change attribute self.jump# to 0
    (inside overlap rule, new rule) When touch is pressed, or space bar is down, whatever you want to jump.
    Change velocity to 90° at whatever speed you want to jump at.
    Change attribute self.jump# to 1.
    Otherwise:
    If attribute self.jump #=1
    Change velocity again.
    Change attribute self.jump# to 2.

    That should work. If it doesn't, just say.
    Asymptoteell
  • flapairflapair Member Posts: 67
    @Asymptoteell

    So i tried your way and i noticed like it only jumps when i touch him or space bar but i want when touches the jump button or space bar. Thanks.
  • AsymptoteellAsymptoteell Member Posts: 1,362
    Make a game attribute game.jump.

    In the jump button, make a rule where when touch is pressed, change attribute game.jump to 1.

    In jump actor, replace touch is pressed with when attribute game.jump is 1.
  • flapairflapair Member Posts: 67
    Their i finally made it! I made the jump work but no the double jump but i did the following code:

    if game.Jump = 1
    Interpolate attribute self.position.y to game.ground position y + 110 | duration: 0.2 seconds
    After 0.3
    Interpolate attribute self.position.y to game.ground position y + 52 | duration 0.2

    but it only works 1 time if i click on the jump again it doesn't work and if i put in the hero:

    if over lapses or collides with actor of type ground
    change attribute game.jump to 0

    then when i click again on the jump it stays on the same position because he is colliding with the ground. and i tried to do the double jump
  • flapairflapair Member Posts: 67
    @Asymptoteell

    Thanks i used you're method on the jump button
Sign In or Register to comment.