I’m trying to get a ball to be able to jump, but when it jumps and lands again it isn’t able to jump a second time, probably due to my misuse of the function onCollisionStay()? Though I’m unsure of what is wrong with my code.
#This is what I have
function Start () {
GetComponent.<Rigidbody>().drag = 2;
}
private var isFalling = false;
var jumpHeight = 8;
function Update () {
var ballRotationX : float = Input.GetAxis ("Horizontal") * 20;
var ballRotationZ : float = Input.GetAxis ("Vertical") * 20;
GetComponent.<Rigidbody>().AddForce(ballRotationX, 0.0f, ballRotationZ);
if (Input.GetButtonDown("Jump") && (isFalling == false)) {
GetComponent.<Rigidbody>().velocity.y = jumpHeight;
isFalling = true;
}
}
function onCollideStay() {
isFalling = false;
}