Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Issues with animation spamming

Discussion in 'Animation' started by Zorro-Games, Jul 10, 2021.

  1. Zorro-Games

    Zorro-Games

    Joined:
    Jul 17, 2016
    Posts:
    5
    Hello, I have a running animation imported and when I hold down A or D it works fine but I can just mash it and it looks janky. Please help :(

    Code (CSharp):
    1.  if (!m_Anim.GetCurrentAnimatorStateInfo(0).IsName("Slashing"))
    2.           {
    3.             if (Input.GetKey(KeyCode.Mouse0))
    4.             {
    5.                 if (Input.GetKey(KeyCode.D) && isGrounded)
    6.                 {
    7.                 Attack();
    8.                 m_Anim.Play("Run Slashing");
    9.                 }
    10.                 else if (Input.GetKey(KeyCode.A) && isGrounded)
    11.                 {
    12.                 Attack();
    13.                 m_Anim.Play("Run Slashing");
    14.                 }
    15.                 else
    16.                 {
    17.                 Attack();
    18.                 m_Anim.Play("Slashing");
    19.                 }
    20.             }
     
  2. KalOBrien

    KalOBrien

    Unity Technologies

    Joined:
    Apr 20, 2021
    Posts:
    61
    In the animator click the transition and uncheck "Has exit time" for the run animation to the idle. This will remove the "jank"
     
unityunity