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
0
Question by soydasmemet · Sep 08, 2016 at 02:30 AM · touchtouch controlscharacter movementmultitouchtouching

How to move and fire at same time with touchscreens? ( multitouch)

Hello Guys,

Could you explain how works goes with the multitouches? I want to move player object with one finger by touch joystick and with the others make fire by tapping ground. But when i move the player and fire with other finger at the same time, it does not perceive the tapping ground activity and this second touch affects on the joystick knob position. I think, i must distinguish the touch on the joystick object, from the other touches at the screen and look only that touch for moving action. How can i do that?

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by MD_Reptile · Sep 08, 2016 at 02:34 AM

Firstly, this has been answered many times in many places, including several other answers on this site, but anyway for the sake of learning here we go!

One thing you must do is enable multi touch input. In your input script (where your listening for button presses or touchscreen taps and whatnot) you will put into Start() or Awake() this code:

 Input.multiTouchEnabled = true;

And then when your checking for input you need to check for more than just a single touch. Something like this:

 int tapCount = Input.touchCount;
  for ( int i = 0 ; i < tapCount ; i++ ) {
        Touch touch = Input.GetTouch(i);
        //Do whatever you want with the current touch.
  }

And so from this point it all depends on what your game is setup like, maybe you need to check the position of that touch and see if it is over the joystick. Then if it is, and no other touch is already interacting with the joystick, have this touch move the joystick. If it doesn't show up over the joystick, maybe it hits a button, or touches the screen where there are no buttons and you should raycast to see what gameobject they are tapping!

Good luck!

Comment
Add comment · Show 1 · 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 soydasmemet · Sep 08, 2016 at 12:45 PM 0
Share

Thanks for the answer and yes, i saw this solution when i searching, but i couldn't figure out if the first touch is on joystick object and after that there are some fire touches on the ground, or the first touch for firing on the ground and the second one is on the joystick for move action. How could i know which one i should track for move?

 //For the first  condition i should track =>             
  Input.GetTouches(0);
 //For the second condition i should track =>        
  Input.GetTouches(1);

So, there can be some other conditions, too. Now, my problem is; how can i know for all conditions which touch is on the joystick and how to distinguish it from the others for move action?

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Unusual multitouch behavior (Android) 3 Answers

How to get multitouch input using EasyTouch 0 Answers

Multi-touch for camera not working? 0 Answers

Multitouch problem 0 Answers

Simultaneous Multitouch Sends The Touch Over and Over 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