Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by pako · Oct 22, 2012 at 01:50 PM · touchmultitouchfingeridphase

Need Clarification on some Touch Struct Variables

After going through all available documentation and quite extensive searches on the internet I'm still not quite clear on how the following are implemented in Unity:

  1. Touch.fingerId: Apparently, an integer is automatically assigned to this variable when a touch occurs. Through Internet searches I found that the first number assigned is 0, and that subsequent touches get assigned numbers in increments of 1, so if 5 fingers touch the screen one-after-another, the fingerId's assigned will be 0,1,2,3,4. My questions are: a. What if the first finger (fingerId=0), is raised and then immediately touches again, and then raised and retouched one more time. Would it lose the fingerId=0 assignment, and get a 5 and then 6 assignment on the subsequent 2 touches? b. What if fingers corresponding to -say- fingerId=2 and 4 were raised, and after some time they retouched the screen, while the other 3 fingers were still touching and with fingerId's=0,1,3. Would the 2 'new' fingers get assigned fingerId's=5, 6, or would they fill the gaps with fingerId's=2,4? In the former case, is there a limit to the sequence of touches, and hence the range of the fingerId's, or is this just limited by the int type? c. Do the fingerId's persist for a 'touch sequence', i.e. until there are no more screen touches, and then the auto-numbering starts from 0 again?

  2. Touch.tapCount: This records number of taps for a specific Touch, and hence for a specific fingerId. However, if a finger is raised TouchPhase.Ended is fired, signifying the end of a Touch, and thus the end of the specific fingerId. So, how can this happen? How can tapCount, report a count of -say- 3 taps for a specific fingerId, if this fingerId gets cancelled once the finger gets raised (after the initial tap) and TouchPhase.Ended is fired?

I thank you in advance for your attention and help.

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Fattie · Oct 23, 2012 at 07:25 PM 0
Share

hey pako for the record. if you follow through the incredibly long example i already linked to, it will fully explain it

put down say five fingers. they will be 0 to 4 in the order you put them down

lift up say the first two, and now only numbers 2 and 3 remain

if you keep your number 3 finger down, for all time the fingerId WILL refer to that one. really it's an incredible system. INCREDIBL$$anonymous$$ if I went back to program$$anonymous$$g native mac code say I'd be unwell.

as i explained at ridiculous length in the linked post, the critical element is that Unity DOES fill from the lowest number up, which is incredibly handy (on most systems until now you had to like match back the id number)

hope it helps

TouchPhase.Ended absolutely fires without fail. you can trust your life on it.

http://answers.unity3d.com/questions/326253/strange-touch-behavior.html#answer-326285

it is all explained at vast length over and over and over right there

And (as it says there :) ) never use the silly GetTouch helper function

it's crap.

it's amazingly easy to use fingerId with Input.touches, even for the most sophisticated handling, as shown

i love input engineering, and unity's system is really great.

(yes, you ignore the silly GetTouch function - but that's just like ignoring networkinstantiate in their awesome networking, no big deal.)

avatar image AlucardJay · Oct 24, 2012 at 12:11 AM 0
Share

consider

 if ( TouchPhase.Ended || TouchPhase.Canceled )

Fattie (or $$anonymous$$ike) : regarding a comment I made on your above link; I mentioned that more than 5 touches would cancel all touches, then Gregzo taught me for iPad you can have 11 touches. So checking the the API for TouchPhase.Canceled I read (for example) the user puts the device to her face or more than five touches happened simultaneously.

API link : http://docs.unity3d.com/Documentation/ScriptReference/TouchPhase.Canceled.html

Without an iPad device it doesn't really affect me but I guess it just means cancelled = number of touches exceeded for the device max input touch length. I probably should ask a question, huh?! (no device = not yet affected) =]

avatar image Fattie · Oct 24, 2012 at 05:24 AM 0
Share

alu one half-answer: I'm pretty sure (A) you can SAFELY IGNORE THE CANCELLED OPTION as the others encapsulate it and I'm quite sure (B) it seems very tittchy, it depends greatly on the device etc / often oes not really exist and (C) unfortunately I never fully investigated it so I can't give you a decisive answer, but it;s an admirable question

regarding the "max number" issue. you are right it totally varies on all sorts of devices. (the fact that they mention "five" on that page is random)

sorry for weak input on this :O

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by whydoidoit · Oct 22, 2012 at 09:05 PM

iOS/Droid is allocating the FingerIds - you should consider them to be opaque because it is doing clever stuff to work out if this is the same finger - this is also the answer to your second question. tapCount can only be greater than 1 if the OS has figured out that this is the same finger.

You use a fingerID to track the movement of a single finger, you should not expect specific values even if they appear to be consistent on some platform, it's certainly possible that the fingerID for real finger would change between calls, despite the best efforts of the OS to make it persistent - so the only thing you might get is the tapCount being > 1 because the OS is reporting that.

Comment
Add comment · Show 8 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image pako · Oct 23, 2012 at 07:12 PM 0
Share

Thank you for your response. If as you say, "tapCount can only be greater than 1 if the OS has figured out that this is the same finger", this means (I think) that TouchPhase.Ended does NOT always fire when a finger is raised (i.e. during a detected tap sequence). I'll do some testing to check things out.

avatar image whydoidoit · Oct 23, 2012 at 10:51 PM 0
Share

No I believe that ended is always fired when a finger is raised and tapcount is greater than one when the os figures out that it is the same finger tapping (probably repeated taps on the same part of the screen in a limited period of time).

avatar image darthbator · Oct 24, 2012 at 05:32 AM 0
Share

I was actually working on understanding tap a LOT the last few days. What it appears to be doing (at least on android devices) is enumerating the number repeated taps at a given screen location. It appears to continue incrementing the tap count as long as the tap is the same fingerID and hitting the same screen coords (I believe there is some fuzz as to if it is exactly the same touch location or not). The var appears to clear when a touch (with ANY fingerID) lands on a different screen coord.

Fattie who has the answer earlier in the thread dumped some debug code on me in my question about the bounding of that variable. I was able to extrapolate it and wrote some test code of my own and that's the conclusion that I ended up co$$anonymous$$g up with.

I don't really feel like that's the "best" way to get the taps. I'll most likely need to write my own "tapCount" method.

avatar image darthbator · Oct 24, 2012 at 07:11 AM 0
Share

I'm not saying I found a bug at all. I am saying the expressed definition of what tapCount does in the script reference is junk.

I am talking about this function

http://docs.unity3d.com/Documentation/ScriptReference/Touch-tapCount.html

I was totally unclear as to how that number was being bounded. When it was reset etc. I was just saying that "tapCount" is not being cleared out when a tocuhPhase ended or anything like that. tapCount seems to be counting the consecutive number of tap at a given screen coordinate by an expressed finger. What causes tapCount to reset to 1 is using that fingerID finger to tap a different screen coordinate.

I'm not in any way questioning the linked answer. Just kinda providing a short form answer based on what I personally have been doing. I was initially under the impression that tapCount was being bounded by some kind of deltaTimer since the last touch ended or something.

avatar image Fattie · Oct 24, 2012 at 07:19 AM 0
Share

Ahh ! I'm glad you mentioned this issue, sorry I misunderstood you previously. i will delete my pointless comment

"tapCount" is a total mystery. obviously it's utterly undocumented so nobody has a clue what it does.

it is fantastic that someone - you - have delved in to this field!

Currently you are the only living person in the universe who has the slighrest clue what it does !

You are like this guy ...

http://en.wikipedia.org/wiki/$$anonymous$$_Livingstone

exploring totally uncharted areas.

So what the heck does it do? what is a "tap" ?? does it happen over time or?

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

¿Unity messing up fingerIDs? [Android] 1 Answer

multiTouch problem when fingers close together (Bug?) 1 Answer

multi-touch woe, index out of bounds? 1 Answer

iPhone Multitouch Problem 1 Answer

Unity Remote 3 and accessing multiple Input.touches? 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges