Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question struggling a bit with animations

Discussion in 'Animation' started by jtrojann, Dec 26, 2022.

  1. jtrojann

    jtrojann

    Joined:
    Dec 7, 2022
    Posts:
    1
    So, i'm trying to make a character jump when i press "space". But the problem is that when it ends it doesnt get back to the idle animation.

    my code is like this:

    if (Input.GetKeyDown(KeyCode.Space))

    {

    playerAnim.Play("IdleJump");

    playerAnim.ResetTrigger("Idle");

    }

    I have tried to use these lines after this "if":

    if (Input.GetKeyUp(KeyCode.Space))

    {

    playerAnim.SetTrigger("Idle");

    }

    But it just makes the animation stop when i release "Space". I know its an easy fix, but i just can't find how.