Swipe to throw a 2D object

Godot Version



Hello! I’m working on a simple mobile project where I “touch” on a RigidBody2D and “swipe” (InputEventScreenDrag) to throw it in the swipe’s direction + swipe’s speed, on release. I tried many solutions but none have been successful. I’d be really grateful if someone could help me with some info or idea on how to achieve this. Thank you!

so this basically just detect on which position it left off and calculate the distance. can be more complicated if you actually count the time before it left off
to detect left off, can easily detect with event.is_released()
to detect input of pressed inside the 2d object, add TouchScreenButton Node.
you might want to Enable the emulate touch from mouse, so you can use the usual mouse left click Input event on touchscreen devices: