Search Unity

How to transition from one melee attack to another in script

Discussion in 'Animation' started by Taka33Taka33, Jun 25, 2022.

  1. Taka33Taka33

    Taka33Taka33

    Joined:
    May 15, 2022
    Posts:
    16
    upload_2022-6-24_20-38-30.png

    That transition from inward slash to outward slash looks really good in the preview.
    I call my attacks with async await like this:

    Code (CSharp):
    1. async void Slash()
    2.     {
    3.         _isAttacking = true;
    4.         await Task.Delay(4000);
    5.         int attackChoice = Random.Range(0, 2);
    6.         if (attackChoice == 0)
    7.         {
    8.             anim.SetTrigger("OutwardSlashTrigger");
    9.  
    10.         }
    11.         else
    12.         {
    13.             anim.SetTrigger("InwardSlashTrigger");
    14.             anim.SetTrigger("ComboTrigger");
    15.         }
    16.         _isAttacking = false;
    17.      
    18.     }
    That ComboTrigger is the transition from inward to outward but it cuts the inward slash way too short so it's basically a weird looking outward slash.
    How do I code it so it's just like in the preview window?