Blend tree 2d platformer jump

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);

mlabarca, did you solve the problem ??? I’m having the exact same issue and can’t get around it :frowning:

you should have an idle animation that is separate from your jump/fall animation. the jump blend tree shouldn’t have any sprites that are in your idle animation. it sounds like your jump/fall is using the idle frame for a zero vspeed. you shouldn’t do that. the blend tree should just default back to your idle animation when grounded.

I had the same problem in my proyect. I changed the Rigidbody2D Interpolate to None and the problem disappeared. Maybe this can help anyone with the same problem.

Hi, @mlabarca

I’m facing this same issue and looking solution for this.
Have you found solution? or can someone look this?
Thanks,

Have you tried attaching a child object called feet with a box collider set as Trigger positioned at the bottom of the character sprite with a script and an OnTriggerEnter2D that sets a value indicating you are touching the ground or have landed? That’s what I have finally had to do.

public class Feet : MonoBehaviour
{
   void OnTriggerEnter2D(Collider2D other)
    { 
        if(other.tag.Equals("Foreground"))
        {
            GetComponentInParent<PlayerMovement>().jumping = false;
        }
    }
}