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
7
Question by NickCh · Dec 30, 2010 at 09:13 PM · animationdouble-clickdouble-tap

How to make double buttons?

What i want to do is to script my char in a way that when the user press W and then W again the the char changes animation.I know how to change the animations...but how to do the double tap button. (W+W immidiately)

Comment
Add comment · Show 4
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 Bob5602 · Dec 30, 2010 at 09:18 PM 1
Share

Wow. I have no idea what the answer is, but, great question!

avatar image PrimeDerektive · Dec 30, 2010 at 09:24 PM 0
Share

What exactly do you mean? Do you mean if the player pushes the button twice immediately, do you want it to play a two animations (the animation from the first press, and the animation for the second press, like a combo)? Or do you want to play only one animation, but a different one if the button is double-tapped? Can you give an example from an existing game?

avatar image NickCh · Dec 30, 2010 at 09:25 PM 0
Share

too bad you have no idea...but thanks for the great question.

avatar image NickCh · Dec 31, 2010 at 08:40 AM 0
Share

Derek i wanna double tap the W and play one animation.Not like double jump.

3 Replies

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

Answer by DaveA · Dec 30, 2010 at 09:43 PM

Sounds like you want a 'double-click' on a key, right? Probably several ways to do it. I'd try something like this:

private var lastTapTime = 0; var tapSpeed = .5; // in seconds, bigger numbers allow more time to detect double-tap

function Update() { if (Input.GetKeyDown ("w")) { if ((Time.time - lastTapTime) < tapSpeed) { changeAnimation(); } lastTapTime = Time.time; } }

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 Jason B · Dec 30, 2010 at 10:07 PM 0
Share

Pretty good way to do it, actually.

avatar image kenja0 · Jul 12, 2011 at 07:01 AM 0
Share

I tried using this code in my project, but it doesn't seem to be working. The double-tap code is always triggering, never once hitting the single-tap code (used as an else).

avatar image
2
Wiki

Answer by MC HALO · Dec 30, 2010 at 09:57 PM

Hi there i found a way but im not sure if its what you are looking for. This simple Java script that i created basically allows you to play to two different animation with the same button:

function Update (){

if(Input.GetKeyDown(KeyCode.O) && Input.GetKeyDown(KeyCode.O )) {

animation.Play("Jump10");

} else if (Input.GetKey(KeyCode.O)){

animation.Play("Jump11"); } }

when you hold down the O Key the Following animation will play Jump 10

and if you press it once it will play Jump 11 :) hope this helps :)

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 Kerihobo · Feb 18, 2015 at 01:01 AM

http://aidtech-game.com/double-tap-button-unity3d/#.VOPjffmUd8E

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Can the animation editor create local rotational data? 3 Answers

Adding animation clips via script 2 Answers

Can I make animations snap to a frame? 1 Answer

How to select an animation clip by index number? 7 Answers

OnPointerDown PointerEventData clickCount not triggering on mobile device (touch) 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