0 votes

Hi, how to determine the movement of the fingers. I make the 2x analog stick.

I made one. but the second finger leads and breaks

global.gd:

var trails = {
    'Control' : null,
    'Control1'  : null
}

Control

extends TouchScreenButton

var pressed
var uname

func _ready():
    set_process_input(true)

func _input(event):
    if(InputEvent.SCREEN_TOUCH == event.type):
        pass
    elif(InputEvent.SCREEN_DRAG == event.type) :
        if global.trails[get_name()] == null and  pressed:
            global.trails[get_name()] = event.index
            for i in global.trails:
                if i != get_name():
                    uname=i
        if(event.index == global.trails[get_name()]) and global.trails[uname] != event.index:
            print(global.trails[uname])
            get_node("Label").set_text(str(event.pos))

func _on_Control_pressed():
    pressed = true

func _on_Control_released():
    pressed = false
    global.trails[get_name()] = null
    get_node("Label").set_text(str(global.trails[get_name()]))

It certainly works but sometimes the touch does not count and skips from the first joystick

I add 2 items ('Control' and 'Control1') and they sometimes conflictual

in Engine by (27 points)
edited by

I don't understand your code fully, but you need to keep the pressed status of each touch index independently. I would suggest using a Dictionary to map active indices to information about touch state.

Please log in or register to answer this question.

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.