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 KetihG28 · Mar 11, 2015 at 09:20 AM · guiswitchtouchscreenattackcombo

Touchscreen Combo System Issue

Hey Everyone, I have been working with a combo script that I've found online some time ago and I wanted to make modifications to it. I've had success with the script and using Input.GetButton commands for a game controller but now I'm having issues with the script in regards to using the touchscreen and guiTextures. I will break my problem down by presenting the issue and stating the goal of what I'm trying to accomplish. Thanks in advance to anyone who has the bandwidth to assist.

Problem: Game is detecting a touch on the screen before and during the animation of an attack. Goal: I'm trying to have the game detect a touch on the screen (kick button, punch button, etc.) only before and after an animation is performed. The catch to this is the fact that I need each tap to represent an animation, i.e. tap 1 should perform "kickAttack1", etc.

Unfortunately the following snippet does two things: the integer tap is incremented and a switch statement is executed.

void Combo () { if(attack && IsComboAnimationPlaying == false) { //Make record of the time from which the player has last pressed the attack button

                       LastPress = Time.timeSinceLevelLoad;

                      //If tap value is greater than 2 set the tap value equal to 1

                             if (tap > 2 && IsComboAnimationPlaying == false) 
                 {
                  tap = 1;
                 } 
         
                else
                {
                 tap++;

                }

         
         //Check to see if the last time the attack button is pressed, is greater than 1 second. If so, reset tap value to zero.
         if (timer - LastPress > 1) 
         {
             tap = 0;
             if (timer - LastPress < Atime) 
             {
                 attack = false;
             } 
             
             else 
             {
                 attack = true;
             }
         }
         switch (tap)
         {
             
         case 0:
             //Reset to Idle
             anim.Play("kyo_idle");
             break;
             
         case 1:
             //Combo Start
             //anim.Play("kyo_lk1");
                 anim.SetBool("kickAttack1", true);
                 IsComboAnimationPlaying = true;
                 Debug.Log ("tap: " + tap);
             break;
             
         case 2:
             //Combo Prolonge
                 anim.SetBool("kickAttack2", true);
                 IsComboAnimationPlaying = true;
                 Debug.Log ("tap: " + tap);
             break;
             
         case 3:
             //Combo Finished
                 anim.SetBool("kickAttack3", true);
                 IsComboAnimationPlaying = true;
                 Debug.Log ("tap: " + tap);
             break;
         }
     }
 }

The code works fine but not in the way I would like for it to work. This next line of code, is a snippet of the condition that I use to start the entire code that you see above.

      if (IsComboAnimationPlaying == false) 
      {

         if (touchKick == true && grounded == true && crouch == false) 
         {
         
             Combo ();
         } 
 
     }

The touchKick boolean is associated with the following:

  if (guiKick.HitTest (myTouch.position, Camera.main) && IsComboAnimationPlaying == false)
  {
   touchKick = true;
   guiKick.color = Color.white;
  }

Again the code works like a charm but it does two things that I HATE: 1) constantly increments tap as many times as you touch the kick button, 2) the code cycles through the switch statement and cause a random animation system to occur, i.e. if I was to tap three times, I would like for the code to execute each case in a chronological order but it just does a random cycle like "kickAttack1", "kickAttack2", and "kickAttack2" or sometimes "kickAttack1", "kickAttack1", and "kickAttack2". I know this is a ton of verbiage and explaination but I'm sure it is a logical fix to this. If anyone has the time and want a unique puzzle to solve, by all means take a look at my dilemna. Any advance, any tips, and suggestions are all welcome here. Thanks for your time.

NOTE: If anyone is wondering what IsComboAnimationPlaying is, it is a boolean used as an Animation Event for each of my animations. When I perform an attack, IsComboAnimationPlaying = true. Once the animation is complete, IsComboAnimationPlaying = false, which is the function I've created to turn IsComboAnimationPlaying off.

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

0 Replies

· Add your reply
  • Sort: 

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

2 People are following this question.

avatar image avatar image

Related Questions

Problem with Android Keyboard/TextField 1 Answer

Resetting Combos 1 Answer

How to do this GUI 2 Answers

Guitexture script to do something a normal key does. 0 Answers

Combo Attack/Animator issue 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