Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by Pacosmico · Jan 06, 2016 at 11:47 PM · androidinputtouchmultitouchfingerid

¿Unity messing up fingerIDs? [Android]

Mar'ri mar'ri, I hope you are fine today.

I am having a problem using multitouch and fast gestures, or rather, discrete touches mistaken as fast moves.
¿ Should I find or make my own touch detection ?¿ Is this a known issue with a simple solution ?
Precise : When making two consecutive taps, very "close in time", Unity tells me it's the same fingerID moving super fast, while the android system notices the difference between touches.

(To test this I activated the "show touches" option of the Android system and made a simple Unity app to draw it's opinion, and it draw a line between the taps, because it thinks it's the same fingerId, but the Android debug does not draw such connection)

Comment
Add comment · Show 2
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 tanoshimi · Jan 07, 2016 at 07:07 AM 1
Share

"very close in time" - like within 1/50sec (or whatever your frame rate is)?

It seems perfectly possible that Unity is polling your touch input at a lower rate than the Android debug utility (which I assume runs at the native OS level), so a finger that is removed and replaced within a single frame's processing would not be noticed by Unity. I don't know this though - just a hypothesis.

avatar image Pacosmico tanoshimi · Jan 07, 2016 at 06:27 PM 0
Share

I hope it's not the case, because then I will be forced to make my own input?? I will make further tests as Bunny says... There still is the chance I made the readings wrong

1 Reply

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

Answer by Bunny83 · Jan 07, 2016 at 04:56 AM

Uhm, are you sure you don't get a TouchPhase.Ended / Canceled and for the second touch a TouchPhase.Began? If the first touch has ended then of course the second touch would get the same fingerID. The FingerID is only valid between "Began" and "Ended / Canceled". The moment you lift the finger from the surface there's no way to keep tracking the finger. At that point the fingerID has lost it's meaning. If a new touch occures (TouchPhase.Began) that finger will get a currently free fingerID. In most cases it's picks the lowest free ID.

Example:

 finger  event   ID
 --------------------
   F1    down    0
   F2    down    1
   F3    down    2
   F3    up      - // id 2 is now free
   F1    up      - // id 0 is now free
   F3    down    0
   F1    down    2

As you can see once we lift finger 1 and 3 those ids are free again. Because finger 3 touched again it gets lowest free id which is 0. If the finger isn't touching the surface it doesn't exist from the point of view of the touch hardware. When finger 3 touches again it's just a "new finger".

Can you post the example code you used to test this? Do you actually check the touch phase?

Keep in mind that with 3 fingers on the screen it's possible that the hardware looses track of one because depending on the positions it's possible that two fingers are "shadowing" the third. It's a similar problem like key ghosting in keyboards. As long as the fingers don't share the same column and row at the same time it shouldn't happen.

     problem             no problem
                           ------(2)
   (1)------(2)         (1)------
    |                    |
    |                    |
    |                    |
   (3)                  (3)

"1" might be invisible to the hardware. I've also seen hardware that has already problems with only two fingers when they are on the same row.

Comment
Add comment · Show 3 · 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 Pacosmico · Jan 07, 2016 at 06:20 PM 0
Share

I'm pretty sure I check that out, but I will make a more precise test just to be sure... I hope to be wrong, since that should fix it, thanks anyway. I'll check it and tell you

avatar image Pacosmico · Jan 07, 2016 at 06:23 PM 0
Share

ah, you are Bunny! Dude you dont know the times I used your answers... you are like an Answer God... you gave me tons of helps with the Unity's GUI system without noticing, ja

avatar image Pacosmico · Jan 17, 2016 at 10:25 PM 0
Share

The problem was exactly what you said (first)... I was messing up...

To confirm this I used a $$anonymous$$onoBehaviour attached to the Camera testing touches... but as a side effect I noticed that Unity seems to show the last recorded state of a finger... meaning.. a finger that makes 3 moves in one frame will only show the last one... and this is important if you are counting on Touch.deltaPosition. You can check this out using this script with the Android debugging feature "show finger position"

 using UnityEngine;
 using System.Collections;
 using System.Collections.Generic;
 
 public class TestDedosGenerico : $$anonymous$$onoBehaviour
 {
     public $$anonymous$$aterial mat;
     public float radioLinea = 3;
     public float[] radiosFiguras = new float[]
         {
             12,11,10,9,8
         };
     public Color colorLinea = Color.white;
         public Color[] colores = new Color[]
         {
             Color.green,Color.cyan,Color.gray,Color.red,Color.magenta
         };
 
 
     List<Touch> touches = new List<Touch>();
 
     List<Vector3> pantalla = new List<Vector3>();
 
 #if UNITY_EDITOR
     void Reset()
     {
         if (mat == null) mat = new $$anonymous$$aterial(Shader.Find("Sprites/Default"));
     }
 #endif
 
     void Update()
     {
         if (Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Escape)) touches.Clear();
         touches.AddRange(Input.touches);
     }
 
     void OnPostRender()
     {
         GL.Push$$anonymous$$atrix();
         GL.LoadPixel$$anonymous$$atrix();
         mat.SetPass(0);
         foreach (Touch t in touches)
         {
             Linea(t.position, t.position - t.deltaPosition, radioLinea, colorLinea);
             Rombo(t.position, radiosFiguras[(int)t.phase], colores[(int)t.phase]);
         }
         GL.Pop$$anonymous$$atrix();
     }
 
     void Rombo(Vector3 a, float radio, Color c)
     {
         GL.Begin(GL.QUADS);
         GL.Color(c);
         GL.Vertex(a + Vector3.up*radio);
         GL.Vertex(a + Vector3.left * radio);
         GL.Vertex(a + Vector3.down * radio);
         GL.Vertex(a + Vector3.right * radio);
         GL.End();
     }
 
     void Linea(Vector3 a, Vector3 b, float radio, Color c)
     {
         Vector3 volumen = (b - a).normalized;
         volumen = new Vector3(-volumen.y, volumen.x, 0) * radio;
         GL.Begin(GL.QUADS);
         GL.Color(c);
             GL.Vertex(a - volumen);
             GL.Vertex(a + volumen);
         GL.Vertex(b + volumen);
         GL.Vertex(b - volumen);
         GL.End();
     }
 }

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

45 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 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 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 avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

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

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

Touch Input madness 2 Answers

Android - touch a 3d object and something happens to it 1 Answer

input touch android help 0 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