How to make a KinematicBody/Sprite always be where the finger of the player is?

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

I want to make a KinematicBody/sprite which is always at where the players finger (mobile) is. Without input lag. Precision is very important. This is in 2D.

:bust_in_silhouette: Reply From: spaceyjase
func _unhandled_input(event):
   if event is InputEventScreenTouch and event.pressed == true:
       (event.position)  # the position of the touch

Literally an example in the docs: Input examples — Godot Engine (stable) documentation in English


InputEventScreenTouch is equivalent to a mouse click event, and InputEventScreenDrag works much the same as mouse motion.