2d topdown jumping

How do I do a jump in top-down 2D?

I am trying to make a 2d top-down Zelda-inspired game in gdevelop, but when I got around to the jumping and falling from cliffs, walls and anything which is higher than ground level (as well as elevated ground), i couldnt make a realistic working jumping effect. (and falling)

What should be happening

I would like it to work in a way that uses collision objects (2- one for falling and one for jumping). If the player isn’t in collision with a jumping collision while he is jumping, he would just jump, going up and then back down. But if he is in collision witha jump collision box, then he would jump, and then be on top of the box. (or instead a variable which determines the height of an object, I would prefer this over the example above)

If Link (player) is on something higher than ground (or lower ground), then there would be a collision on the edges, so he falls.

I have been at this for a month and can’t find a solution. I would greatly apriciate if anyone could. I’ve also looked at other projects, but they have not been much help. Thank you!

Hi there were these two from from last year …hove you looked at these yet?
the first one - ive got a platform character in top down and i create a hidden platform object under it when needed. You can turn the platform character behaviour and or the platform behaviour off and on and its a case or getting the logic in the right order.
Make my character jump - Top Down Behaviour - How do I…? - GDevelop Forum
Anyone made this already - faking a jump effect in top-down? - GDevelop general - GDevelop Forum
i think that there’s other threads on this too

Thanks, but I have already tried this method and found it quite confusing. :face_with_diagonal_mouth:

What are you using for your top down forces and collisions at the moment?
Its going to get a bit confusing because you’ll be switching between two systems but make sure that each is isolated using a boolean variable. There’s a few different ways to do it depending on what you’re trying to do. You could do things like switch the player object to just a shadow on the floor and then create or show a player jumping object that works with a different system and then delete or hide itr when it lands again.

I’ve tried 2 ways. Number 1: using forces and collision boxes. I send a force up when the player has pressed the “space key” and then a force down. If he is in collision with a collision box, then he gets a little more force applied so he can reach the box, and when the player is above the collision box and is in collision with it, then it keeps the player away from the box.

Number 2: when the player presses the space bar, he jumps in platformer behaviour and top-down is disabled, then he falls bc of platformer behaviour, and that behaviour gets disabled, switching again to top-down behaviour. If the player collides with and is close enough to the collision box, then he lands on the box, with the “keep away from object” event; if not, he is just sent to where he was previously.

I think if you’re having trouble with one object turning behaviours off and on - why not use two objects as i said above. I’m too tired at the moment to have a go at it - but you might find it less problematic than switching between behaviours

Ok, thanks, I shall try your method!

Hello! I’ve managed to come quite far with this, but I cannot seem to finish it off: (under jump group)


Is there any way you could help?

Hi - im trying to work out what you’ve done. Where are you simulating jump key press?
so the player has top down and platform character attached?
The player object mask has platform behaviour - where is this created?
im finding the is in collision playerY<objectmaskY then separate objects confusing - can you describe your intension here.
later i’ll have a go at it …got domestic responsibilities to take care of first!

1 Like

ok - so this is one way to do it…you don’t have to do it this way. So ive not used platform behaviour just topdown behaviour and set the yspeed to 0 while jump is true. I’ve used variables to apply a force that uses lerp to go from 800 to -700


top down jump3

1 Like

Thanks, I’ll try it out in a bit. Thanks for the help!! :slight_smile:

I’ve just implemented this in the code, I’m a bit confused - what do fallspeed and maxjumpspeed mean?

Hi Rowan - yep its a bit confusing - maxjumpspeed is the start speed of the jump and fallspeed is the speed that speed that jumpspeed is lerping (changing to) to - the third term in the lerp expression is the rate at which the speed changes. i think i had maxjumpspeed at 600 and fallspeed at -600 but ive deleted it now