I am trying to make ball jumping program but every time I try Jumping the ball falls
very slowly. Here is my code:
-------------------------------------------------------------------------------------
#pragma strict
var rotationSpeed = 100;
var jumpHeight = 15;
var jumpHeigtht2 = 0;
var isFalling = false;
function Update ()
{
// this is to Handle the Ball rotation.
var rotation : float = Input.GetAxis("Horizontal") * rotationSpeed;
rotation *= Time.deltaTime;
GetComponent(Rigidbody).AddRelativeTorque(Vector3.back * rotation);
// this is to help the ball jump.
if (Input.GetKey(KeyCode.W)&& isFalling == false)
{
GetComponent(Rigidbody).velocity.y = jumpHeight;
}
else
{
GetComponent(Rigidbody).velocity.y = jumpHeigtht2;
}
}
function OnCollisionStay ()
{
isFalling = false;
}
function OnCollisionExit ()
{
isFalling = true;
}
-------------------------------------------------------------------------------------