how to create swipe controls?

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

i’m creating a platformer and been switching between different controls and recently after a lengthy discussion with my brother we came to agreement that using swipe controls would be the best choice with adding buttons and joy sticks as a option at a later date. ive tried different ways but its always either continues moving after releasing or moves forward abit. i want it to be a 2d platformer where the main goal is to collect items before the time runs out and release it on android before july. ive already done most things before so things such as collectibles, power ups, enemies etc arent that new to me but ive never done swipe controls and cant figure out how to do it. ive been trying for the past week also i want it to be a kinimatic body rather than rigid as it has severel pros and im more used to that also it gives me abit more control over jump as that is one of the most important part of the game

:bust_in_silhouette: Reply From: LoneDespair
#Try to experiment with different values(Didn't test any of this)
const SENSITIVITY_JUMP := -10
const SENSITIVITY_SLIDE := 15

#This wont be called if a GUI or something else is handling the event
func _unhandled_input(event):
  If event is InputEventScreenDrag:
    # The faster the swipe, the higher the relative value
    var swipe = event.relative
    if swipe.y < SENSITIVITY_JUMP : jump()
    elif swipe.x < -SENSITIVITY_SLIDE : left()
    elif swipe.x > SENSITIVTY_SLIDE : right()

#Also enable "emulate touch from mouse" to test from pc