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 jghall1 · Nov 07, 2014 at 08:04 AM · c#androidmultiplayermobilemultitouch

Two player touch screen

I'm trying to create a game in which two players play on the same device. One player (hereinafter Player1) will control a character while the other player (hereinafter Player2) spawns enemies. Player 1 moves with a simple raycast script to follow the finger. It is detected as Mouse(0). Inside a rectangle that is the bottom half of the screen, a Mouse(1) hit makes the Player1 attack. This all works just fine. The issue comes when trying to spawn the enemies. I cannot work out touchId or get it to identify as any mouse buttons when I click the spawn button. I have tried GUI.button, GUItexture, and detecting touches within a rectangle. If Player(1) is moving, Player2 cannot spawn enemies. I am coding in C#. I can post scripts if needed. Thanks in advance.

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 Andres-Fernandez · Nov 07, 2014 at 08:06 AM 1
Share

It would help if you posted the code you use to manage the input from the users. Also, if you are managing many touches I suggest you use the Input.touch and Input.Touches directly and forget about $$anonymous$$ouse. Check the tutorial on multi touch here.

avatar image screenname_taken · Nov 07, 2014 at 09:12 AM 0
Share

If it is not spawning enemies when the other player is touching and directing the player, it's because of $$anonymous$$ouse(0). As Andres said, use input.touch.

avatar image ashique · Nov 07, 2014 at 09:28 AM 0
Share

Search for mul$$anonymous$$ch script...

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by rsMici · Nov 07, 2014 at 09:38 AM

Are you using code like this? I just managed to get my working for two player touch input.

 if (Input.touchCount == 1) {
             Touch touch = Input.GetTouch(0); 

 else if (Input.touchCount == 2) {
             Touch touch = Input.GetTouch(0); 
             Touch touch2 = Input.GetTouch(1); 

Hope i helped you :) took me few days

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 screenname_taken · Nov 07, 2014 at 09:38 AM 0
Share

That one though only works with two fingers. If you put it in a for loop as the documentation says, you can detect as many fingers as your screen can handle.

avatar image jghall1 · Nov 09, 2014 at 07:26 PM 0
Share

Thanks for the quick response. I am not home at the moment but will try this and let you know my results as soon as I get home.

avatar image jghall1 · Nov 09, 2014 at 11:58 PM 0
Share

I'm running into an issue in that the mul$$anonymous$$ch should work across multiple scripts. I am also not sure what to do with the touches once i have them. Would you do something like if(Input.touches[touch].phase == Touchphase.began) { or something else? I can't seem to figure it out.

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

6 People are following this question.

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

Related Questions

Android: After the third touch all touches get cancelled 1 Answer

Programmatically changing brightness setting on Android using c# 0 Answers

2D multi touch 1 Answer

Camera.main.WorldToScreenPoint(touch.position). Help !!! 1 Answer

Needing help with mobile multiplayer. 2 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