Topic was automatically imported from the old Question2Answer platform.
Asked By
klaoye
I want make a controller about mutil touch.(three fingers touch screen as meanwhile)
What I want to get second finger’s position when I using function"InputEventScreenTouch::get_position", but I only got first finger’s position and also “index” is 2.
I`m so sorry for my English,but I must to searching some solution for this problem.
Thanks very much.
var first_pointer_position
var second_pointer_position
var third_pointer_position
func _input(event):
if event is InputEventScreenTouch:
match event.get_index():
0:
#first pointer
first_pointer_position = event.position
1:
#second pointer if any
second_pointer_position = event.position
2:
#third pointer if any
third_pointer_position = event.position
Now you could create a var in global space for each pointer position and assign them each in their designated block like the above code or you could do the following
var pointers = {}
func _input(event):
if event is InputEventScreenTouch or event is InputEventScreenDrag:
pointers[event.get_index()] = event
Then access it like this
#Second pointer position
pointers[1].position
You can even take it a step further and use an enum to avoid confusion