Platformer jumping with forces

I don’t want to use any extensions. I want my player to come up when space is pressed, and continue to go up for a second or two, and then come down, but when I press SPACE, nothing happens. My events:

If Space pressed, add force at -90 degrees, with 50 speed to player. Start jump timer.

When jump timer reaches 2 seconds, end all forces.

But pressing SPACE does nothing, whatsoever. How do I make this work?

Hey,

This can be done trough Behaviours. This are not extensions, but necessary functions built in the game engine.

I suggest you take a look into that thread here.

But I have made anyways the project that you were asking for step by step.

Firstly you will need the platformer character Behaviour, and in there you can change the max falling which is currently set on 1500 px* 1/s speed and Jump sustain time in seconds, which I have set it on 2s.

Secondly you will need to add this piece of code :

This is I hope something you were looking for.

@Danijel
Sorry to say this i think (I don´t want to use any extensions)

I’m confusing extensions and behaviors, I guess. They are extremely parallel. What I meant was, with only the default forces, rather than by using the platformer or even physics behaviors.

Are you applying an instant or permanent force? It should be permanent.

Can you post a screenshot of the pertinent events.

Here’s the whole “jumping” external events.


The other events don’t have any bounds, I don’t think. I’m pretty sure they don’t conflict with the ability to shoot up into the air, but if nothing else, here’s gravity.

I’m not entirely sure you can apply multiple forces at one time without a behavior, though.

The force needs to be permanent otherwise it only applies it on 1 frame. The angle should either be 270° or -90. I prefer 270.

gdevelop_co

Okay. That did it. But it shakes and refuses to jump unless you press the button again. Why might this be? I mean, it’s just great for a rocket, but not for a little person.

It could be the gravity. Try it with that event disabled.

It is. The gravity is constantly affecting the player for as long as the player is not touching a platform. So I changed it slightly. If the player object variable jumping is false, then gravity works. If the timer for jumping is over, the force that throws the player upward is stopped, and the variable jumping is no longer true. If something is no longer true, then it is false. And the gravity force is activated then.

1 Like

Why do you want not to use behaviors?
Are you doing homework?