The Longer You Touch, The Higher He Jumps?

FreiGamesFreiGames Member Posts: 158
edited November -1 in Working with GS (Mac)
So as the title says I'm having a hard time making my character jump higher the longer I touch! :'(

Any suggestions what to do?

Thanks, cheers! :D

Comments

  • SlamuelSlamuel Member Posts: 10
    Seems like you need to set velocity on your character. So what you probably have so far is a Jumping Rule with a keyboard key to make him jump. So add a change attribute in that same rule, stating self.Motion.Linear Velocity. Y To 400.( Or to any number of your liking.)

    Try it out and hopefully you are done with that! Let me know if it doesn't work out.

    Hope that helps,
    Slamuel
  • HachikoHachiko Member Posts: 330
    What I do in my Running template, is basically this:
    when player touch screen, add to the pos Y of the player the max possible height of the jump (i.e, 90) and store the value in a self.attribute. Then, change velocity Y to a value that determine the speed of the jump and take away accelerate down/gravity (so accelerate down only if player isn't jumping). Then, if player.y gets higher than that self attribute we stored earlier, put gravity/acceleration back. Also, put gravity/acceleration back if player lift the finger. And that's pretty much it :)
  • FreiGamesFreiGames Member Posts: 158
    Thanks to both of you will try 'em out now!
  • FreiGamesFreiGames Member Posts: 158
    I can't make any of those work :(
    Someone got template?
  • HachikoHachiko Member Posts: 330
    FreiGames, I got one example inside the running template but it's on sale for 50$ plus other code examples. You can take a look at it in the marketplace.
    But if you don't want or can't pay any money, I'll try and explain an easier version of it. It's not as optimized, but it should be easier to understand.
    You've got gravity/or acceleration down set.
    Rule:if player touch screen and an attribute playerCanJump is true (meaning, he is on solid ground and can jump, so you should have another rule that check if he is on ground)
    change a self attribute to position y of the player + max height of the jump (i.e, if the player is at posY 100, and max height is 90, result will be 190. If the player reach 190, jump will be disabled)
    constrain attribute motion linear Y of the player to 300 (this value determine the min height of the jump, and also the speed of the jump itself, we use constrain because we don't take out acceleration before, like I explained in the other post. That's why this is easier but not that performant).
    Now like this the player will jump, but never going down.
    So we add a rule.
    If player left finger from touch OR player.position.Y is equale or greater than self.attribute which we stored that 190 earlier then
    attribute.canJump = false.

    Setting it back to false will stop the constrain, so the acceleration or gravity will kick back in and get him back to the ground.
  • FreiGamesFreiGames Member Posts: 158
    Hachiko said:
    FreiGames, I got one example inside the running template but it's on sale for 50$ plus other code examples. You can take a look at it in the marketplace.
    But if you don't want or can't pay any money, I'll try and explain an easier version of it. It's not as optimized, but it should be easier to understand.
    You've got gravity/or acceleration down set.
    Rule:if player touch screen and an attribute playerCanJump is true (meaning, he is on solid ground and can jump, so you should have another rule that check if he is on ground)
    change a self attribute to position y of the player + max height of the jump (i.e, if the player is at posY 100, and max height is 90, result will be 190. If the player reach 190, jump will be disabled)
    constrain attribute motion linear Y of the player to 300 (this value determine the min height of the jump, and also the speed of the jump itself, we use constrain because we don't take out acceleration before, like I explained in the other post. That's why this is easier but not that performant).
    Now like this the player will jump, but never going down.
    So we add a rule.
    If player left finger from touch OR player.position.Y is equale or greater than self.attribute which we stored that 190 earlier then
    attribute.canJump = false.

    Setting it back to false will stop the constrain, so the acceleration or gravity will kick back in and get him back to the ground.

    Ok thanks a lot I'll try this out first if I can't make it work I'll buy the template!

    Cheers!
  • FreiGamesFreiGames Member Posts: 158
    YES!!!!
    It worked, thank you SO much, if there is ever anything I can do for you let me know!
  • HachikoHachiko Member Posts: 330
    Just glad you sorted it out! :D
Sign In or Register to comment.