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
0
Question by junaum · Feb 23, 2012 at 04:23 PM · touchjoystick

How to manage different touch Pads

Hi,

I'm failing to achieve a simple solution for this problem. I've recently posted this question, but it sounded really confusing, so I'm getting back with some more objective information. I'm in a dead end for weeks now.

Having the screen divided in two areas (touchZones), and then, logging touches per starting point (if the touch started on the left or right area, independently from where it ended). My limited programing experience isn't helping much. I would love if one of you could shade some light on this matter.

Here is a simple picture that describes what I'm trying to achieve:

alt text

Touches starting on Pad A will be computed as "A" while touches starting at B, will be computed as "B". In the end, this is about having the right side of the screen (B) dedicated to touch swipes, while keeping the left area (A) for a dynamically spawning JoyPad.

As of now, my code goes like this (but it isn't working as intended... touches are getting mixed when ending/canceled). The "getTouchOutput" is running at Update.

 function getTouchOutput () {
     
     var i : int = 0;
     var count : int = Input.touchCount;        
 
      if (count > 0) {
     
         if (!touchStartSet[i]) {
         
             while(i < count) {
             
                 touch[i] = Input.GetTouch(i);    
                 touchFinger[i] = touch[i].fingerId;
                 
                 touchStart[i] = touchCurrent[i] = touch[i].position;    
                 touchStartSet[i] = true;
                 
                 if (touchZone.Contains(touchStart[i])) touchPad[i] = true;
                 else touchPad[i] = false;    
                 
                 i++;
             }
         }
             
         else {
         
             while(i < count) {    
                 
                 if (touchPad[i]) touchDraw(touchPrevious[i], touchCurrent[i]);                    
                 else joyDraw(touch[i].position, touchStart[i]);
                     
                 touchPrevious[i] = touchCurrent[i];                                             
                 if (touch[i].position != touchPrevious[i]) touchCurrent[i] = touch[i].position;    
                 
                 touchOutput[i] = setTouchMotion(touchPrevious[i], touchCurrent[i]);    
                 
                 if (touch[i].phase == TouchPhase.Ended || touch[i].phase == TouchPhase.Canceled )
                     resetTouch(i);    
                                         
                 touch[i]  = Input.GetTouch(i);
                 
                 i++;
             }            
         }
     }
 }
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

0 Replies

· Add your reply
  • Sort: 

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Android on 2nd touch destroy... 1 Answer

Player doesn't stop jumping when stop touching the screen[Android] 1 Answer

How to make virtual joystick (Windows Store)? 1 Answer

Joystick Zone + Screen-swipe touch input clash. Solution??? 1 Answer

[HELP] Joystick Movement/Button Movement 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