Holding Down Key allows actor keep going up

KCDKCD Member Posts: 24
edited June 2012 in Working with GS (Mac)
I am trying to create a jumping effect but I cant seem to put a maximum jump height on the actor. When I press once the actor will go down. When I hold down the actor continues to go up. How can I get the actor to automatically go down regardless of how long I hold down the spacebar?

Best Answers

  • HC_DKHC_DK Posts: 92
    Accepted Answer
    Take a look at the PLATFORMER TEMPLATE inside the GameSalad program.
  • The_Gamesalad_GuruThe_Gamesalad_Guru Posts: 9,922
    Accepted Answer
    Put in a timer that forces the actor back down after a predetermined amount of time.
  • SlickZeroSlickZero Houston, TexasPosts: 2,870
    Accepted Answer
    For the basic jump function, you can do this...
    Make a rule that says
    when "spacebar" (or whatever) is pressed
    change attribute - self.motion.linear velocity.Y to self.motion.linear velocity.Y +500 (or whatever number works best)

    And to keep from having your character jumping every time you tap the spacebar, you will need to set up an attribute to see if the character is touching the ground or in the air. When the character is touching the actor that is acting as the ground, just have a boolean set to true when colliding, and in the otherwise statement, have the boolean set to false. So the script will look like this.

    when "spacebar" (or whatever) is pressed and attribute "touching ground" is true
    change attribute - self.motion.linear velocity.Y to self.motion.linear velocity.Y +500 (or whatever number works best)

    This will keep the actor from launching completely out of the game if someone repeatedly taps the jump button.
Sign In or Register to comment.