playMaker

Author Topic: Multiple Touch fingers at the same time.  (Read 3792 times)

mihaivladan

  • Playmaker Newbie
  • *
  • Posts: 2
Multiple Touch fingers at the same time.
« on: April 13, 2014, 06:15:14 AM »
Hi, ive just started working with Playmaker and im trying to save the position of 2 or 3 fingers that touch the device at the same time. Based on those individual coordinates i would like to Create an object there.

So far ive tried it the following way : simply add 2 instances of touch event and assign 2 different global variables to them ( see attached image ) . However this does not work as intended : both values are the same if i touch with 2 fingers.

Can someone please help me out with how i can achieve this ?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Multiple Touch fingers at the same time.
« Reply #1 on: April 14, 2014, 08:24:18 AM »
Hi,

 yes, you can't really hardcode variables for this.

typically, you have one prefab to listen for touches

1: you listen to the first touch
2: as soon as you have one finger down, you lnstantiate the prefab again, it will catch the second touch.
3: etc etc, for as mayn touch you want to support.

 since you MUST listen to the Began state of a touch, the prefab records the finger id locally on its fsm, not globally.

bye,

 Jean

mihaivladan

  • Playmaker Newbie
  • *
  • Posts: 2
Re: Multiple Touch fingers at the same time.
« Reply #2 on: April 15, 2014, 01:38:06 PM »
Hi,

 yes, you can't really hardcode variables for this.

typically, you have one prefab to listen for touches

1: you listen to the first touch
2: as soon as you have one finger down, you lnstantiate the prefab again, it will catch the second touch.
3: etc etc, for as mayn touch you want to support.

 since you MUST listen to the Began state of a touch, the prefab records the finger id locally on its fsm, not globally.

bye,

 Jean

Hi Jean,

Thank you very much for the quick and thorough reply.
If you don't mind and have the time , can you please look over what i've made based on your suggestion ? Here is the project https://dl.dropboxusercontent.com/u/8717019/Touch%20Test.zip .

It works most of the time , but there are some instances where i only get 1 touch even thou there are 2 fingers.

Thank you again for your help!
Kind regards,
Mihai

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Multiple Touch fingers at the same time.
« Reply #3 on: April 21, 2014, 08:29:00 AM »
Hi,

 a bit behind, allow me few more days, thanks :)

bye,

 Jean