How can I walk into a hole in godot.

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

I am using a kinematicbody2d and CollisionShape2D for my player. I made a hole 16 pixels wide but the character just hovers over the hole and does not fall down. How do I fix this and make it pixel perfect?

:bust_in_silhouette: Reply From: Magso

It’s kinematic so all movement has to be scripted. The gravity needs to be continuously added when the player is not on the ground.

var gravity : float
export var gravity_amount : float

func _physics_process(delta):
    if !player.is_on_floor():
        move_and_slide(Vector2(side_movement, gravity))
        gravity -= gravity_amount
    else:
        #reset gravity
        gravity = 0