I have created a ball game where the player ball must necessarily jump immediately , but with this script the ball after the first jump , jump only after 4 seconds , i need that the player ball must jump immediately , how can I fix this script?
#pragma strict
var jumpObject : Rigidbody;
var jumpDelay : boolean;
var canJump : boolean;
var groundTag : String = "Ground";
var jumpHeight = 10.0;
var doublejumpHeight = 7.5;
private var doubleJump : boolean;
function OnCollisionEnter(col: Collision) {
if (col.gameObject.tag == groundTag) {
doubleJump = false;
canJump = true;
}
}
function OnCollisionExit(col: Collision) {
if (col.gameObject.tag == groundTag) {
canJump = false;
}
}
function Update () {
if(canJump == true && Input.GetKeyDown(KeyCode.Space)) {
jumpObject.velocity.y = jumpHeight;
doubleJump = true;
}
if(canJump == false && doubleJump == true && Input.GetKeyDown(KeyCode.Space)) {
jumpObject.velocity.y = doublejumpHeight;
doubleJump = false;
}
}