Hi I have a 2d character jumping multiple times and too high. How can I make it jump only once?
Here’s the script:
public float speedforce = 5.0f;
public Vector2 jumpVector;
public bool isGrounded;
public Transform grounder;
public float radius;
public LayerMask Ground;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
isGrounded = Physics2D.OverlapCircle (grounder.transform.position, radius, Ground);
if(Input.GetKey(KeyCode.UpArrow) && isGrounded == false) {
GetComponent<Rigidbody2D>().AddForce (jumpVector, ForceMode2D.Force);
}
}
}
Any help would be appreciated