In my jump script there is a statement that says, if not grounded and moving along the y axis, grounded = true however, this statement doesn’t seem to be active.
using UnityEngine;
using System.Collections;
public class Jump : MonoBehaviour {
public bool grounded = true;
public float jumpPower = 50000;
// Use this for initialization
void Start () {
grounded = true;
}
void Update () {
if(!grounded && GetComponent<Rigidbody2D>().velocity.y == 0) {
grounded = true;
}
if (Input.GetButtonDown("Jump") && grounded == true) {
GetComponent<Rigidbody2D>().AddForce(transform.up*jumpPower);
grounded = false;
}
}
}
Is there something wrong within my script? The problem is that I can only jump once.