Double Jumping

oxheyoxhey Member Posts: 28
edited July 2012 in Working with GS (Mac)
I have a character who can jump an unlimited number of times.

I want to make it so that it can only jump twice ( jump then , boost jump) before it needs to touch the ground so it can jump again.

My current code for the character is this :

When atribute (game.jump) = true

change (self.Motion.Linear Velocity.Y) to 450

Best Answers

  • master200012master200012 Posts: 372
    edited July 2012 Accepted Answer
    Make an attribute (integer) within the actor who is jumping. Call it "jumps."

    When the actor is overlapping or colliding with the ground,

    constrain attribute (jumps) to 0
    -----
    Now for your code.
    -----
    When attribute (game.jump) = true
    AND attribute (self.jumps) < 2

    change (self.Motion.LinearVelocity.Y) to 450


    Hope this helps!
  • JohnPapiomitisJohnPapiomitis Posts: 6,256
    edited July 2012 Accepted Answer
    Make an attribute (integer) within the actor who is jumping. Call it "jumps."

    When the actor is overlapping or colliding with the ground,

    constrain attribute (jumps) to 0
    -----
    Now for your code.
    -----
    When attribute (game.jump) = true
    AND attribute (self.jumps) < 2

    change (self.Motion.LinearVelocity.Y) to 450


    Hope this helps!
    No need for a constrain, you can just use a change attribute to change jumps back to 0 when he hits the ground.

    And you want it to be when jump is true and jumps < 2
    change attribute jumps to jumps+1
    change self motion linear velocity y to whatever
Sign In or Register to comment.