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 DiebeImDunkeln · Jan 09, 2015 at 01:24 PM · touchgrid based gamepinch

clickable grid and pinch zoom

Hi,

I have a clickable grid (by touch) and need to make a pinch zoom, but my problem is that evertime if I try to pinch zoom, Unity gets the first finger touch and thinks it's also a click on the grid and is moving my player sprite.

Is there a way to check if it is a short tap or a pinch zoom gesture?

thanks in advance Frank

Comment
Add comment · Show 8
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 hypnoticmeteor · Jan 09, 2015 at 01:38 PM 0
Share

Create a small delay of 0.5 seconds before it assumes it is a click.

avatar image DiebeImDunkeln · Jan 09, 2015 at 01:50 PM 0
Share
 void Update()
 {
 
        
  #if UNITY_IPHONE || UNITY_ANDROID || UNITY_WP8
  $$anonymous$$ouseEnabled = false;
         
  if (!PlayerController.is$$anonymous$$oving && Input.touchCount == 1)
  {
                
    HandleInput();
  
  }
  #endif
 }

this is how I check the tap. Could you give me an example for the delay check?

avatar image hypnoticmeteor · Jan 09, 2015 at 02:21 PM 0
Share

should have thought of this before. Create a new test to check if number of touches is 2.

 void Update () {
         if (Input.touchCount == 0)
             return;
         if (!PlayerController.is$$anonymous$$oving && Input.touchCount == 1)
         {
             HandleOneTouch();
         }
         else if (!PlayerController.is$$anonymous$$oving && Input.touchCount == 2)
         {
             HandleTwoTouch();
         }
         else if (!PlayerController.is$$anonymous$$oving && Input.touchCount == 3)
         {
             HandleThreeTouch();
         }
         else
         {
 
         }
     }



avatar image DiebeImDunkeln · Jan 09, 2015 at 02:25 PM 0
Share

The problem is, in the moment if I place 2 fingers on the device it recognizes first a Input.touchCount == 1 before is gets Input.touchCount == 2. It's impossible to touch with 2 fingers exactly at the same time.

avatar image hypnoticmeteor · Jan 09, 2015 at 02:36 PM 0
Share

Hmm thought it should work. Let me try something.

Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by DiebeImDunkeln · Jan 13, 2015 at 04:41 PM

I tried it, but that was not solving my problem.

I handle it now with a coroutine within the PinchZoom with a delay for a comeback. While Pinch is active the touch of the fields below are deactivate. After ending the pinch I active the fields again with a delay of 0.5 second.

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
avatar image
0

Answer by hypnoticmeteor · Jan 10, 2015 at 11:53 AM

 using UnityEngine;
 using System.Collections;
 public class MonitorTouch : MonoBehaviour {
 
     int touchCount;
     void Update()
     {
         touchCount = 0;
         foreach (Touch touch in Input.touches)
         {
             if (touch.phase != TouchPhase.Ended && touch.phase != TouchPhase.Canceled)
                 touchCount++;
 
         }
         if (touchCount == 3)
         {
             //handle if 3 touches
         }
         if (touchCount == 2)
         {
             //handle if 2 touches
         }
         if (touchCount == 1)
         {
             //handle if 1 touch
         }
 
     }
 }


Tried and tested.

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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

multiTouch problem when fingers close together (Bug?) 1 Answer

grid-based block placement system with touch input 1 Answer

How to centre a 3D pinch zoom 1 Answer

Hello I'm trying to write a C# about "Pinch to zoom" but it doesn't work 1 Answer

Pinch zoom 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