Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 antk · May 12, 2014 at 06:29 PM · touchswipetap

Tap for variable height jump, swipe to dash

Hi,

This may be a weird/interesting question. I'm currently working on a 2D, side scrolling, endless running game. Current touch input accounts for the following:

tap - jump swipe right - speed boost swipe down - drop to platform below

I've coded it so that my character can also do variable height jumping - meaning the longer the touch is held, the higher the character jumps - so I set the character to jump on touchphase.began.

Well the issues start when the player swipes right - the character will jump first, then dash (which makes sense since I'm also setting the character to jump on TouchPhase.Began. The best I've been able to do is cancel as much of the initial jump as possible by setting the rigidbody velocity to zero, then executing my dash code - but it looks awkward.

Any thoughts on how to approach this? I can't do tap detection on TouchPhase.End because the character won't jump until the player lifts their finger off the screen.

I've tried TouchPhase.stationary, but it's pretty iffy.

Any other thoughts?

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

· Add your reply
  • Sort: 
avatar image
0

Answer by OrbitGames · May 12, 2014 at 06:36 PM

You can check for the the delta position on the first touch. If it is smaller than some number, than you jump, oterwise use swipe input.

This could be over sensible , so another option would be to jump once the finger is released, but it feels kind of awkward if the character doesn't jump immediately.

I would check after about two or three frames (you have to play around with this number) what the total deltaPosition is, so that is somewhat of a mixture of the two answers named above.

Comment
Add comment · Show 2 · 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 antk · May 14, 2014 at 05:37 AM 0
Share

Thanks for your answer, I'll give it a try. How do you check "two or three frames" later?

avatar image reidkiller antk · Mar 26, 2018 at 12:59 AM 0
Share

Did you ever get an way out of it @antk? if u did, can you share with us please? (Talking about your main problem, to don't jump on swipes)

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

22 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

Related Questions

Custom touch phase? 0 Answers

Unity 2D. How to swipe without detecting tap? 2 Answers

Differentiating a tap from a swipe? 1 Answer

Single Tap Registered on Swipe (C#) 0 Answers

Detect whether a tap is a swipe up gesture or just a tap 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