Detection move 2 x touches happening (or more)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Jond
:warning: Old Version Published before Godot 3 was released.

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

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.

raymoo | 2017-11-08 19:30