Hello, I’m making a simple game, but the problem I have is that there is an option for infinite jumping, which I would like to cancel, I tried several options that I found on the Internet, but every time they made me unable to jump. I have all platforms set to Ground
code:
{
private Rigidbody2D rb;
[SerializeField] private AudioSource jumpSoundEffect;
private void Start()
{
rb = GetComponent<Rigidbody2D>();
}
private void Update()
{
float dirX = Input.GetAxisRaw("Horizontal");
rb.velocity = new Vector2(dirX * 7f, rb.velocity.y);
if (Input.GetButtonDown("Jump"))
{
jumpSoundEffect.Play();
rb.velocity = new Vector2(rb.velocity.x, 14f);
}
}
}