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 /
  • Help Room /
This question was closed May 11, 2016 at 12:23 PM by OkkoLOBR for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by OkkoLOBR · May 10, 2016 at 12:16 PM · 2d gametouch

Non consistant 2D Touch result

Hi,

I'm working on a game involving display of 10 to 100 game objects at the same time. Player has to touch one of the game object. And here's where my trouble start. Game is in 2D, using an orthographic camera. All my game objects have RigidBody2D and Box Collider 2D.

Most of the time, it works correctly, but sometimes game seems to fail to catch user's touch.

Here is the code I use in my "main" script.

 if (Input.touchCount > 0)
         {
             Touch userTouch = Input.GetTouch (0);
             Vector3 wp = Camera.main.ScreenToWorldPoint(userTouch.position);
             Vector2 touchPos = new Vector2(wp.x, wp.y);
             Collider2D hit = Physics2D.OverlapPoint (touchPos);
             MyOtherScript myGameObject = hit.attachedRigidbody.GetComponentInParent<MyOtherScript> ();
 
             if (!myGameObject.isClicked && userTouch.phase == TouchPhase.Began)
             {
                 myGameObject.SomeFunction ();
             } 
 
         }

At first, I suspected my phone to not catch correctly touch, but I've tested on different device, both iOS and Android, and I got the same result : touch works 95% of the time, but fail the rest. And it brings to pretty frustrating gameplay...

Some more information on gameplay : once a game object is touched, game test if it is the right one (SomeFunction() ), remove all game object from the screen and display some fresh game object.

Does anyone would have an idea to help me ?

Thanks in advance !

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

  • Sort: 
avatar image
0
Best Answer

Answer by OkkoLOBR · May 11, 2016 at 12:22 PM

After several additional tests, it seems that the main issue was size of actual game object which were a bit too small, resulting in unprecise touch.

Made them bigger, and have now a pretty satisfying feeling when playtesting.

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

Follow this Question

Answers Answers and Comments

67 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 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

Error CS1026: Unexpected symbol ;, expecting ) 0 Answers

UI Image not firing function constantly when held down. 1 Answer

Conditionals using TouchPhase.Ended 0 Answers

Simple cell-based game goes bonkers when clicked on the edge of the cell 0 Answers

How can I move my player up and down in a Top-down shooter for mobile/android? 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