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 /
This question was closed Nov 23, 2013 at 02:30 PM by ozturkcompany for the following reason:

Other

avatar image
0
Question by ozturkcompany · Nov 04, 2013 at 12:10 AM · androidmulti-touchdelta position

(UNSOLVED) Touch.deltaPosition on two fingers??How??

Hi, i have been messing with this for a while not but i couldn't figure out how to do it.. What i have been trying to do is get an output of two independent fingers deltaPosition.Here is the code i was trying to get it from. All of the help is appreciated.Thank you.

function Update () {

for (var touch : Touch in Input.touches) {

if (touch.fingerId == 1) {

delta1 = Input.touches [0].deltaPosition;

}

if (touch.fingerId == 2) {

delta2 = Input.touches [1].deltaPosition;

}

}

}

Comment
Add comment
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

2 Replies

  • Sort: 
avatar image
1

Answer by Sparrowfc · Nov 19, 2013 at 06:55 AM

 int touchID1 = -1;
 int touchID2 = -1;
 float deltaPos1, deltaPos2;
 
 void Update()
 {
     //first, record actived touchID
     foreach(Touch t in Input.touches)
     {
         if(t.phase == TouchPhase.Began)
         {
             if(touchID1 == -1)
                 touchID1 = t.touchID;
             else if(touchID2 == -1)
                 touchID2 = t.touchID;
         }
         else if(t.phase == TouchPhase.Ended || t.phase == TouchPhase.Canceled)
         {
             if(t.touchID == touchID1)
                 touchID1 = -1;
             else if(t.touchID == touchID2)
                 touchID2 = -1;
         }
     }
 
     //second, track the touch
     foreach(Touch t in Input.touches)
     {
         if(t.touchID == touchID1)
         {
             deltaPos1 == t.deltaposition;
         }
         else if(t.touchID == touchID2)
         {
             deltaPos2 == t.deltaposition;
         }
     }
 }
Comment
Add comment · Show 9 · 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 gajdot · Nov 19, 2013 at 07:08 AM 0
Share

Basically you could do the second part in the same for loop as the first, just check for TouchPhase.$$anonymous$$oved and the id-s you are looking for.

avatar image ozturkcompany · Nov 23, 2013 at 12:34 PM 0
Share

didn't work! I still get the delta positions of two finger when one of them stationary.When both of the finger moves only one delta value is shown! $$anonymous$$Y GOOOOOOOD!!!!

avatar image Bunny83 · Nov 23, 2013 at 12:48 PM 0
Share

$$anonymous$$aybe your device doesn't fully support mul$$anonymous$$ch? I have a nexus 7 (the old one) and i can have 10 simultanous touches without any problems. You can try my $$anonymous$$obileStats app(android only) and see if they work.

$$anonymous$$ay i ask how you "show" the deltas?

avatar image ozturkcompany · Nov 23, 2013 at 12:57 PM 0
Share

Thank you for the app i'll try it now. $$anonymous$$y phone is samsung s3 $$anonymous$$i and the programs inside of it shows that multi touch is supported.I use guitexts to write down the delta values to screen.The problem is i can get the positions of each finger on the screen simultanous ly but cannot get the deltaPositions.You see that there are two variables delta1 and delta2 and they represent their touch.deltaPosition. When i write touch.position i can get the positions of them simultanously.I think there is sth wrong with that ".deltaPosition" code inside unity3d.

avatar image ozturkcompany · Nov 23, 2013 at 01:00 PM 0
Share

Hi man it doesn't work as well as in your apk.I see that when i put 2 of my fingers simultanously only the last finger's deltaPos is shown and other one is zero?? But i can drag multiple cubes at the same time? if you havent done it with deltaPosition to move them around how did you?

Show more comments
avatar image
0

Answer by Essential · Nov 04, 2013 at 12:36 AM

Try this:

 function Update ()
 {
     for (var touch : Touch in Input.touches)
     {
         if (touch.fingerId == 0)
             delta1 = touch.deltaPosition;
         else if (touch.fingerId == 1)
             delta2 = touch.deltaPosition;
     }
 }
Comment
Add comment · Show 12 · 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 ozturkcompany · Nov 04, 2013 at 05:49 AM 0
Share

Hey, thank you for the reply but nothing is changed.Well actually the code above is no differente than i did though.

avatar image ozturkcompany · Nov 04, 2013 at 05:53 AM 0
Share

What i want to achieve is that when i put two of my finger on the screen and when i move two of my fingers at the same time independently,i want to know each finger's deltaPosition in realtime when i move my fingers simultaneously.Could someone give me a hand on this or point me out a way of doing it? Thanks

avatar image Essential · Nov 04, 2013 at 07:49 AM 0
Share

Why doesn't the code above work for you?

avatar image Essential · Nov 04, 2013 at 07:50 AM 0
Share

Tell me what you want to do. Why are you trying to get the deltas of two fingers?

avatar image cornel · Nov 04, 2013 at 07:53 AM 0
Share

If you want the delta of each finger then you have already done that. $$anonymous$$aybe you want the delta of the point between the fingers ? And then when you move your fingers, the middle point will also move and you want to get the delta of the middle point.

Show more comments

Follow this Question

Answers Answers and Comments

19 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

Related Questions

Problem with multi touch 1 Answer

ITouch multi touch with joystick problem 0 Answers

Android Touch Variation Correction? (How to use Screen.dpi?) 2 Answers

Smoother Android Movement with deltaPosition 1 Answer

How to use touch.deltaPosition properly? 1 Answer


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