how to fix character infinite jump?
using UnityEngine;
using System.Collections;
public class Player : MonoBehaviour {
public Animator Anim;
public Rigidbody2D PlayerRigidbody;
public int Pulo;
public bool punch;
//verifacador de chao
public Transform GroundCheck;
public bool grounded;
public LayerMask whatisGround;
//soco tempo
public float socoTempo;
public float tempoTempo;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
// se o pulo for apertado e estiver pisando no chao, faca isso
if(Input.GetButtonDown("Jump") && grounded== true) {
PlayerRigidbody.AddForce(new Vector2(0, Pulo));
}
if(Input.GetButtonDown("Fire2")) {
punch = true;
tempoTempo = 0;
}
grounded = Physics2D.OverlapCircle(GroundCheck.position, 0.2f, whatisGround) ;
if(punch == true)
{
tempoTempo += Time.deltaTime;
if(tempoTempo >= socoTempo)
{
punch = false;
}
}
Anim.SetBool ("soco", punch);
}
}