Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

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.