0 votes

I need to get the position of a touch continuously . When I use InputEventScreenTouch, it only gives position when the touch is pressed/released. When I use InputEventScreenDrag, it only gives position when it is dragged, but not when it is held in one place. My problem is that I can't get position of touch while it is being held down in one place. Any ideas how to solve this?

Godot version 3.3.3.stable.mono
in Engine by (195 points)

1 Answer

0 votes

InputEventScreenTouch is the one you want. As you said, each event has pressed and released. Once its pressed that means touch is active and it is active. Once touch is removed event is fired with same index id with "pressed" variable false. That means touch was active until now.

extends Node
var first_touch

func _input(event):
    if event is InputEventScreenTouch:
        if event.pressed :
            first_touch = event
            # Touch is pressed from now on
        if !event.pressed and event.index == first_touch.index:
            first_touch = null
            # first touch was just removed.
by (153 points)
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 Frequently asked questions and 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 [email protected] with your username.