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 /
  • Help Room /
This question was closed Dec 20, 2018 at 03:54 PM by avalanchesoldier for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by avalanchesoldier · Dec 13, 2018 at 06:01 PM · animationcombo

Combo Animation interruption

Hello everyone, this is my first time posting here. I've been looking around on the site and haven't found a clear cut answer. I'm not saying it's not out there, but I haven't been able to find an answer. Basically, I'm a novice when it comes to Unity animation. My combos all seem to hit the enemy, however, the animations don't always play and the hits seem to land regardless of whether the animation plays or not. I have a feeling that's it's mostly due to the way my IEnumerator's are set up in order for the animations to play for a certain period of time instead of constantly playing. Currently, I'm able to get the first 2 animations playing but the third is not. Here is my code. Please feel free to call out redundancies as well how messy my code is. I haven't done this in a long time and am going back to school in January. Any and all help would be appreciated!

 void Update()
 { 
     if(Input.GetKey("t"))
     {
         comboCount = 1;
         attack1 = true;
         attack2 = true;
         attack3 = true;
     }
         if(Input.GetKey("j") && comboCount == 1 && attack1)
         {
             time = Time.deltaTime;
             StartCoroutine("Attack1");

             Collider2D[] enemiesToDamage = Physics2D.OverlapCircleAll(attackPos.position, attackRange, whatIsEnemies);

             for (int i = 0; i < enemiesToDamage.Length; i++)
             {
                 enemiesToDamage[i].GetComponent<Enemy>().receiveDamage(damage);
                 OnTriggerEnter2D(enemiesToDamage[i]);
             }
            
             //timeBtwAttack = startTimeBtwAttack;
         }
     Debug.Log(attack1 + " " + attack2 + " " + attack3);

     if (attack1 == false && Input.GetKey("j") && comboCount == 2)
     {
         StartCoroutine("Attack2");

         Collider2D[] enemiesToDamage = Physics2D.OverlapCircleAll(attackPos.position, attackRange, whatIsEnemies);

         for (int i = 0; i < enemiesToDamage.Length; i++)
         {
             enemiesToDamage[i].GetComponent<Enemy>().receiveDamage(damage);
             OnTriggerEnter2D(enemiesToDamage[i]);
         }

     }

     if (attack2 == false && Input.GetKey("j") && comboCount == 3)
     {
         StartCoroutine("Attack3");

         Collider2D[] enemiesToDamage = Physics2D.OverlapCircleAll(attackPos.position, attackRange, whatIsEnemies);

         for (int i = 0; i < enemiesToDamage.Length; i++)
         {
             enemiesToDamage[i].GetComponent<Enemy>().receiveDamage(damage);
             OnTriggerEnter2D(enemiesToDamage[i]);
         }

     }
     //else
     //{
     //    timeBtwAttack -= Time.deltaTime;
     //}
 }

 void OnDrawGizmosSelected()
 {
     Gizmos.color = Color.red;
     Gizmos.DrawWireSphere(attackPos.position, attackRange);
 }

 IEnumerator Attack1()
 {
     playerAnim.SetBool("isAttacking1", true);
     yield return new WaitForSeconds(0.15f);
     playerAnim.SetBool("isAttacking1", false);
 }

 IEnumerator Attack2()
 {
     playerAnim.SetBool("isAttacking1", false);
     playerAnim.SetBool("isAttacking2", true);
     yield return new WaitForSeconds(0.15f);
     playerAnim.SetBool("isAttacking2", false);
 }
 IEnumerator Attack3()
 {
     playerAnim.SetBool("isAttacking2", false);
     playerAnim.SetBool("isAttacking3", true);
     yield return new WaitForSeconds(0.15f);
     playerAnim.SetBool("isAttacking3", false);
 }
 public void OnTriggerEnter2D(Collider2D enemy)
 {
     if(enemy.gameObject.tag == "Boss")
     {
         enemyHit = true;
         if (comboCount == 1)
         {
             Invoke("disableAttack1", .1f);
         }
         if (comboCount == 2)
         {
             Invoke("disableAttack2", .1F);
         }
     }
 }
 void disableAttack1()
 {
     if (comboCount == 1)
     {
         attack1 = false;
         comboCount++;
     }
 }
 void disableAttack2()
 {
     if (comboCount == 2)
     {
         attack2 = false;
         comboCount++;
     }
 }

 void comboWait()
 {
     comboCount++;
 }
 void resetCombo()
 {
     comboCount = 1;
 }

}

Comment
Add comment · Show 3
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 cdr9042 · Dec 14, 2018 at 08:42 AM 1
Share

Have you looked into Animation Event? You can place events in the animation timeline https://docs.unity3d.com/$$anonymous$$anual/animeditor-AnimationEvents.html

avatar image avalanchesoldier cdr9042 · Dec 15, 2018 at 04:42 PM 0
Share

I have not, but I will now! Thank you for the tip!

avatar image avalanchesoldier cdr9042 · Dec 20, 2018 at 03:53 PM 0
Share

Hey, I got things figured out with Animation Events. Just wanted to say thanks again!

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

313 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 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 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 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 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 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 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 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 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 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 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 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 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 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 avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity Glitch? Weird Blend Tree Combo Problem 0 Answers

How to make button rotate when another button is pressed? 0 Answers

2D ball rolling animation 0 Answers

game win animation with effect or animation.,show full display message with animation 0 Answers

Trying to animate using Breadcrumb(Asset) 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