Basically I just want to be able to make the object jump, but whenever I start the game, the ball ends up floating up. I believe the issue lies within either line 20 or 17, but I could very well be mistaken.
#pragma strict
var rotationSpeed = 100;
var jumpHeight = 8;
private var isFalling = false;
function Update ()
{
//Ball rotation.
var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
rotation *= Time.deltaTime;
var rigidbody: Rigidbody = gameObject.GetComponent(Rigidbody) as Rigidbody;
GetComponent. ().AddRelativeTorque (Vector3.back * rotation);
if (Input.GetKeyDown(KeyCode.W) && isFalling == false);
{
rigidbody.velocity.y = jumpHeight;
}
isFalling = true;
}
function onCollisionStay ()
{
isFalling = false;
}
↧