hey, i am creating a game. It is a simple game where you should rotate and jump a ball on a ground
so here is my code:
#pragma strict
var rotationSpeed = 100;
var jumpHeight = 8;
private var isFalling = false;
function Update ()
{
//Handle ball rotation.
var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
rotation *= Time.deltaTime;
GetComponent.<Rigidbody>().AddRelativeTorque (Vector3.back * rotation);
if (Input.GetKeyDown (KeyCode.W) && isFalling == false)
{
GetComponent.<Rigidbody>().velocity.y = jumpHeight;
}
isFalling = true;
}
function OnCollisionStay ()
{
isFalling = false;
}
but i am having a problem, after few seconds of launching my game the ball deviate from axis and fall down from the platform.
please i need your help.