Skip to main content

You're asking for the y property of the Vector2 you created, which is 0. You set the input to vec2.x

Try:

void FixedUpdate () {
    rigidbody2D.velocity = new Vector2(0, Input.GetAxis("Vertical") * VerticalSpeed);
    anim.SetFloat("VerticalSpeed", Mathf.Abs(rigidbody2D.velocity.y));
}
Hamza Hasan
  • 3.4k
  • 2
  • 15
  • 24