I’m having some issues with player collision and sometimes even when the player has collided with something, grounded still = false. I want to create a scenario that makes it when grounded = false for more than 2 seconds, grounded goes back to = true.
ideas? THANKS!
using UnityEngine;
using System.Collections;
public class JumpTwo : MonoBehaviour {
public bool grounded = true;
public float jumpPower = 1000;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyUp ("space") && grounded == true) {
GetComponent<Rigidbody>().AddForce(Vector3.up*jumpPower);
grounded = false;
print ("Jump");
}
}
void OnCollisionEnter ()
{
grounded = true;
}
void OnCollisionExit()
{
grounded = false;
}
}