Simulating jump in a top down 2D game

Hi,

I would like to achieve something like the jump in Rpg Maker:

https://i.redd.it/26c01j0rvsjd1.gif

I tried converting an old code I used in Unity (that worked) but there are some issues and I don't know if it's the best way to achieve it in Godot and GDscript.

Here's the code:

func jump(distance, time = 0.4):

`if is_jumping:`

    `return`



`var destination = position + (facing * distance)`

`var jump_height = distance * 0.5`

`var timer = 0.0`



`while timer <= 1.0:`

    `var height = sin(PI * timer) * jump_height`

    `position = position.lerp(destination, timer) + Vector2(0, height)`

    `timer += get_process_delta_time() / time`

    `await get_tree().create_timer(0.01).timeout`

Here's what happens in Godot:

https://i.redd.it/idxcnzewvsjd1.gif

as you can see the "arc" is in the wrong direction when jumping right or left and, also, it's not complete like it stops in the middle and then the character goes down straight.

Can you help me understand how to achieve the same jump as in Rpg Maker?