[Solved] FSM - Pressure jump

Hi guys, I’m implementing jump pressure, if the button is pressed quickly, the character jumps minimally, if it’s pressed for a certain time it goes up more and consequently stays in the air a little longer.

Before everything. I know how the FSM works, I’m just not being able to implement this idea!

But I have a problem touching the wall, when I do that the character simply goes up, until the wall ends or I release the jump button.

I made a video to explain it better:

FSM Before Jump

FSM Jump:

Note that I removed the “Trigger once” so that I can be controlling the character in the air, but when it reaches a speed above 300 it should go into the “Falling” state

What I noticed is that when entering the “Falling” state, the character keeps jumping if it’s on a wall, and it doesn’t have a jumping state when it’s “falling”. That is, theoretically, when entering this state, the character should automatically fall and not fly like this…

This only happens with this airtime implementation. If I put the “trigger once” it works normally.

To me, this sounds like you are reaching falling before you hit 300 jump speed, which is definitely possible due to gravity.

Have you tried adding a text objext that contains a string with expressions for the current jump speed, falling status, and jumping status?

That may help you debug easier.

Yes, I did a speed debug, and it goes over 300, that is, it is not falling in this condition.
I even made this small change:

Even so, it exceeds 300

That’s possible - take the case of jump speed being 290, then it’ll increase it by 20, pushing it up to 310.

WRT the FSM, what do you do when the state is falling?

The way I see it from the event’s you’ve posted, if you’ve just set the jump speed to over 300, the simulate jump key has also just been actioned, and the object will need to complete that before gravity takes over.

But then in the event immediately after it, you set the state to falling, even though the jump action from the simulated jump key press still needs to be completed.

I found the error, or bug I don’t know. But I would like you to explain it to me.

I was using the following command for character movement when jumping.

So far so good, it worked well, because I used pressure on analogs to walk or run.

But when I went back to “normal” mode, everything worked out.

Why? What is different from one to the other?

A few best guesses:

  1. Forces do not play well with platform behaviors, or any behaviors, really. You probably should never mix them if you can avoid it.
  2. I don’t think doing (minus sign) (expression) behaves very well in most cases. You probably want to do something like -(expressionhere) or -1 * (expression here).

GDevelop’s expression parser supports unary operators, I’ve never had any problem with those before either :thinking:

I made an example here to demonstrate what’s going on.

Download

Press ‘S’ to change the way you walk. Then:

  • Walk normally jumping with both modes
  • Jump with jump button pressed (note that pressing the button works)
  • Touch the wall and press jump, with both modes
  • Touch the wall by moving against it

As for expression, I never had a problem either, just like Arthuro.

OK, after a lot of thinking and redoing the code, I made two changes that made all the difference.

Change walk to normal platform mode, but set analog pressure to “maximum speed”:

And 2: change the “Jump speed of”, to “Jump sustain time”

Fixed issue. I only have a doubt now with the issue of the negative state. Because Silver-Streak commented that it could be a problem. What to do in this case?

If Arthuro believes that using - with an expression will work fine, I would trust him over me. I might be remembering wrong.

1 Like