Direction change, de-accelerate

So working on a 2D platformer and I can’t crack the code and chatgtp has been useless on this… which is probably a good thing in the long run. This will be my 5th night on this.

Anyway I’m trying to make make my character do a small skid/de-accelerate before changing directions when you push the opposite way. At the moment he changes direction straight away and it doesn’t feel good. Any ideas what logic options would be good for this.

As always any help is always appreciated.

Indeed, ChatGPT (at least the 3.5 version) is not very helpfull with Gdevelop : It mixes Gdevelop with other tools and thus is not reliable.

What are you using ? The PlatformerObject Behavior ?

You will probably need to turn off the “Default control” button on the “PlatformerObject” behavior, and handle yourself what happens when the player presses the movement keys. (Explore the Actions “Simulate xxx key press” on your player ).
Now, find a way to detect when the player is changing direction. And instead of directly using the action “Simulate xxx key press” in the new direction, apply first a force in the opposite direction to your caracter, check when its speed is 0 (or reversed its direction) and then apply “Simulate xxx key press” in the direction you wish.

I hope that it helps…

Cheers for the input. I will try the logic you have suggested tonight. I turned off the default controls after about a week of trying to fix the bunny hopping side effect in any effective manner.

Quick question would you check speed with maybe a variable that changes between say true and false for if character is moving… and in contact with ground. Something like that?

1 Like