Search Unity

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.