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 JA_555 · Sep 08, 2014 at 10:00 AM · iostouchtap

Unity double tap explanation

This is the code given by Unity docs for a double tap that makes a projectile. I would like to learn how this code works and if possible, how I can edit it even further, for example, make it a single tap instead of a double tap. Thanks

 var projectile : GameObject;
 function Update () {
     for (var i = 0; i < Input.touchCount; ++i) {
         if (Input.GetTouch(i).phase == TouchPhase.Began) {
             clone = Instantiate (projectile, transform.position, transform.rotation);
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 markzareal · Sep 08, 2014 at 10:05 AM 0
Share

I think you can use http://docs.unity3d.com/ScriptReference/Input-touchCount.html

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Graham-Dunnett · Sep 08, 2014 at 10:58 AM

The code you post (copied from the docs for Input.GetTouch) does not require a double tap. The example looks to see if any touch has started, and fires the projectile. Most mobile devices support multi-touch, and the for() loop looks at each of the touches. There is a way to detect a double tap, and that's to use:

http://docs.unity3d.com/ScriptReference/Touch-tapCount.html

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
avatar image JA_555 · Sep 08, 2014 at 07:09 PM 0
Share

Actually, the script I posted supports double tap as well, but what I'm looking for is a way to edit this so it can it works with a single tap, NOT double tap. From there, I can make other edits, but I can't do that if the only thing I'm looking at is var tapCount: int; There is no explanation for what to do with this

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

How is "Touch.tapCount" bounded? 1 Answer

touch game objects on ios 1 Answer

Detect a tap versus standing touch on iPhone? 3 Answers

Remove Y-axis clamp from Tap to Move, Drag to Look Script 0 Answers

OnMouseDown works fine for iOS 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