3.1 - Problem with gravity in 2D

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By fpicoral

Guys, I’m trying to migrate a project from 3.0.6 to 3.1.beta2 but I’m having a litte problem:
My game is a plataform game 2D and I use the following code to apply the gravity (the fall function its called on _physics_process(delta):

func fall(delta):
    if  is_on_floor() or is_on_ceiling():
        motion.y = 0
    else:
        motion.y += GRAVITY * delta

It works fine on 3.0.6 but not in 3.1.beta2. In 3.1, when the player colides with a ceiling, he gets stuck in tge ceiling.

I even tried removing the motion.y = 0 but doesn’t really matter the motion.y value, if the player touches the ceiling, he will get stuck.

If you want to try in your computer, here is the project on GitHub

:bust_in_silhouette: Reply From: fpicoral

I fixed removing the else and putting motion.y += GRAVITY * delta outside the if. I really don’t know why it’s doing that on 3.1 but removing the else was the only solution I could find.

:bust_in_silhouette: Reply From: punkramenaz

I figured out a curious solution before seeing here that this a bug:
I converted constant “UP” to a variable value so when “is_on_ceiling” is “true” i inverted the second value from -1 to 1, making gravity upside-down…