How to check force or velocity on character?

Hi!

I am making a 2D game and I want to change animations based on force tests. I have the jump working like this:

if(jump) 
    {
        rigidbody.AddForce(transform.up * jumpForce); 
        onGround = false; 
        jump = false;
    }

And I want to animation to over-write other animations depending on the force up on the rigidbody. So if it is positive, make it a jumping up animation, and if it is negative make it a falling animation. Otherwise, other animation checks apply. So my character couldn't run in mid-air...

How do I go about doing that?

1 Answer

1

Use rigidbody.velocity. In your case, you'd want rigidbody.velocity.y to get the falling speed. (Y is the up and down axis)

Great that's exactly what I needed, thanks :)

Cool, glad I could help. :)