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 mightybob · Nov 25, 2015 at 08:58 PM · androidiosiphoneswipetap

Differentiating between a tap from a swipe on Android

I'm trying to differentiate a tap from a swipe. I have it in my game so if you tap the screen, the character on the screen jumps, and if you swipe down, he slides/ducks. The problem is, I can't seem to figure out how to differentiate a tap from a swipe. The character will always jump, because the jump code is simply:

if (Input.touchCount > 0) { Jump(); }

I've seen some people ask the same question, and some people answer "check time.deltaTime and see if it has moved or stayed still", this seems like a good way to do it, but I'm not sure how to do it.

Comment
Add comment · Show 1
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 sHajir · Feb 09, 2017 at 07:56 AM 0
Share

Hi, did you find out how to differentiate a touch and a swipe ? I'm having the same problem. i tried to solve it via

-TouchPhase.Began (get current position)

-TouchPhase.$$anonymous$$oved (check current position with position from began ->if difference is big then it is a swipe and no tap )

-TouchPhase.Ended (check current position with position from began ->if difference too is small then it is a tap and no swipe)

$$anonymous$$y Problem: tap is recognized too late, when my finger leaves the screen. This is because of TouchPhase.Ended. I'm looking for another solution.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by callen · Nov 25, 2015 at 09:16 PM

I think all you need is to become familiar with the Touch class, and Input.Touches

The TouchPhase and deltaPosition should be all you need, but the class has more data you may be able to utilize as well.

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

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

IOS Swipe Gesture 0 Answers

UI Buttons not always working on Android? 0 Answers

Simultaneous Android and iOS development 1 Answer

Device Auto-Rotation 1 Answer

Ampersand in application name 4 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