So, I created a jumping animation for my 2D platformer character, and it seems to only play the first frame of it, and only for a very small fraction of a second. I used the Animator, and created a transition from “Any State” to my jump animation with the requirement that a bool called IsJumping is true. This is how I establish whether it is true or not:
if (Input.GetKeyDown(KeyCode.Space))
{
jump = true;
animator.SetBool("IsJumping", true);
}
...
public void OnLanding()
{
animator.SetBool("IsJumping", false);
}
I call OnLanding in an Event that triggers when the character is on the ground.
Yes, I remembered to uncheck Can Transition to Self. Thanks for any answers!
@MrKathooloo
I had this same problem and i believe we are using the same “charactercontroller” .
Aight so the problem is that the moment you press the jump key you are still on the ground. this causes the “onlanding” event to trigger which turns off the jump animation. (i believe you will find if you double tap the jump button the jump animation will play mid air). this can be solved by making it so it only stops the jump animation every second time the “onlanding” event happens (meaning it wont stop the animation from playing as soon as you jump but will when you land from the jump)(u must take into account the first “onlanding” when the game starts). These are the changes and additions that fixed this problem for me:
public bool Testjump = false;
public int LandCount = 0;
public void Onlanding() {
if (Testjump == false)
{
if (LandCount == 0)
{
LandCount = 1;
}
else
{
Testjump = true;
}
}
else
{
animator.SetBool("isjumping", false);
Testjump = false;
}
}