as you can see from the video idk why my character make those little jump when i stop press D while im on the hill.
imaginativescarediberianbarbel
my code:
public class characterMovement : MonoBehaviour
{
private Rigidbody2D body;
private Animator animator;
public float speed = 3.0f;
public float jumpHeight = 6.0f;
public Vector2 direction;
void Start()
{
body = GetComponent<Rigidbody2D>();
animator = GetComponent<Animator>();
}
void Update()
{
direction = new Vector2(Input.GetAxisRaw("Horizontal"),0);
}
private void FixedUpdate() {
body.velocity = new Vector2(direction.x * speed, body.velocity.y);
animator.SetFloat("MoveX", direction.x);
}
}