I want that the player ball must not jump when it is in the air , but only when the ball is on the ground How do I make jump the ball only when the ball touches the ground ?
--------------
--------------
Code:
var jumpDelay : boolean;
var doubleJump : int = 0;
function Update()
{
if(Input.GetKeyDown(KeyCode.Space) && jumpDelay == false)
{
Jump();
}
}
function Jump()
{
if (doubleJump <= 1)
{
rigidbody.velocity.y = 10;
jumpTimer();
}
}
function jumpTimer()
{
if (Input.GetKeyDown(KeyCode.Space))
{
doubleJump ++;
}
if (doubleJump > 1)
{
doubleJump = 0;
jumpDelay = true;
yield WaitForSeconds(3);
jumpDelay = false;
}
}