Hi, I am trying to setup a platform jump/fall animation using blendtrees such as the one in this tutorial:
http://unity3d.com/learn/tutorials/modules/beginner/2d/2d-controllers
I’m using a vertical speed as parameter. Problem is that when the characther lands on its feet the vertical speed is zero, which is the same as in the top of the jump, thus that animation is picked briefly until my “ground” bool is set back to false.
Of course moving the groundcheck up makes that bool get set faster, but this makes it so people can jump again before even landing.
Making a normal animation would then disable the falling part, which is the cool part of the blend tree.
The only workaround i can think of is somehow detect when when i’m at the top of the jump, and create 2D blendtree that doesn’t play that top-of-the-jump animation when the characther lands. Does that make any sense? Here be the related parts in my characther controller.
void Update () {
if (grounded && Input.GetKeyDown (KeyCode.Space))
{
rigidbody2D.AddForce (Vector2.up * jumpForce);
anim.SetBool("ground",false);
}
grounded = Physics2D.Linecast (transform.position, groundCheck.position, whatIsground);
anim.SetBool("ground",grounded);
h = Input.GetAxis ("Horizontal");
// If the player's horizontal velocity is greater than the maxSpeed...
if(Mathf.Abs(rigidbody2D.velocity.x) > maxSpeed)
// ... set the player's velocity to the maxSpeed in the x axis.
rigidbody2D.velocity = new Vector2(Mathf.Sign(rigidbody2D.velocity.x) * maxSpeed, rigidbody2D.velocity.y);
}
void FixedUpdate () {
grounded = Physics2D.Linecast (transform.position, groundCheck.position, whatIsground);
anim.SetBool("ground",grounded);