+1 vote

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

Godot version version 3.2.3
in Engine by (15 points)

1 Answer

0 votes
#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
by (383 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.