holding down jump makes jump bigger

0 favourites
From the Asset Store
Make your own platformer for both the web and mobile easy with this Santas Platformer Template, FULLY DOCUMENTED
  • Hi,

    i am creating a one click jumping game, what i want is for the player to jump higher the longer they hold the jump key down.

    At the moment the way i have it working is that when they hold down the jump key it adds power to the sump strength and then when they release the button the player jumps. The strength being set by how long you held the key down for.

    What i want to do is when the jump button is pressed the player jumps immediately and stays in the air until they release the key (up to a certain maximum jump strength. So the longer they hold the jump button down for while in flight the higher they will jump.

    There are some other posts on something similar but none of them actually seem to do this... any help?

  • This is just how I would try..

    Let's say the maximum jump height you want is 50

    sysytem for every tick if jump button is down and maximum jump height is less than 50 add 1 to maximum jump height.

    could that work?

  • I tend to do this the same way the old Sonic games did.

    When the player clicks to jump, set the vertical speed to, say, -10. Then when they release, check to see if the speed is less than -3. If it is, set it to -3. If it isn't, don't do anything.

    You'll want to fine-tune those numbers a lot depending on different aspects of your game like sprite size and all that though.

  • PixelMonkey has it right. The simplest way to do this is to add an event that sets the vertical speed to 0 when the jump button is released. This makes the character start falling as soon as the button is released. THe transition can be a bit harsh, so that's why PM gave the -3 value. That makes the transition to fall smoother.

  • Yeah, perhaps I should elaborate more on what the numbers actually do. =b

    The 10 is the speed at which the jump starts, so for a higher jump set that one higher.

    The -3 is the speed that it is set to to slow the jump. A 0 would stop the jump immediately, but it tends to look unrealistic for all movement to stop entirely. Also, putting in a negative value will allow you to have small jumps if the player releases the mouse immediately after clicking.

  • This is what I do, and it is variable (so not just 2 heights of jump)

    Basically, if the player is jumping, and jump key is released, and yvector < 0, just divide yvector by some number (2 is a good start).

    This will give variable jump height.

  • PixelMonkey: hi, that sounds like exactly what i want to do. Which movement behaviour would you use for that and which specific event do you mean? just want to make sure i am using the right thing for my tests thanks.

  • It will work with Platform behaviour, using the Set Vector Y event. For checking the vertical speed you'll need to use an expression like Player.Platform.VectorY, as there isn't a condition for checking the individual X and Y speeds.

    So like this:

    <img src="http://img7.imageshack.us/img7/3298/screencap01.png" border="0" />

    Just swap out Space with whatever you want as input (in your case, probably the mouse), swap Player with whatever object you have that needs the variable jumping, and tune the numbers a little to see what looks best.

    Hope this helps you.

  • Thanks again pixel monkey, I did a lot of playing around with those variables and managed to get what I needed the game to do, thank you. :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Just tried to pull this off myself. It's nearly there but can you clarify how to put that system expression in PM? I must just be missing something but I can't find any system field to put that expression in.

    Thanks in advance!

  • if jumping and if jumpButton is not down

    set vectory to vectory + additional fall speed

    Wouldn't that work?

  • Thanks PixelMonkey, works like a charm.

    For those having trouble finding the compare like slw666, its in System->General->Compare two values

    Sadly after implementing this I had to ditch it because my player has a wait attached to his jump. This is to allow for a scrunch down in the animation before jumping. The wait appears to be enough to nullify a distinguishable difference in time for the space press.

  • PixelMonkey thanks I was looking for it

  • This thread is pure gold. Thanks for just happening to answer my question too :)

  • This thread is pure gold. Thanks for just happening to answer my question too :)

    Ditto

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)