my object will only jump one time but, it is suppost to jump multipule times. i don’t know what is wrong with my code.
#pragma strict
var rotationSpeed = 100;
var jumpHight = 8;
private var isFalling = false;
function Update ()
{
//handle ball rotation.
var rotation : float = Input.GetAxis ("Horizontal") * rotationSpeed;
rotation *= Time.deltaTime;
GetComponent.().AddRelativeTorque (Vector3.back * rotation);
if (Input.GetKeyDown(KeyCode. Space) && isFalling == false);
{
GetComponent.<Rigidbody>().velocity.y = jumpHight;
}
isFalling = true;
{
Function onCollisionStay ();
{
isFalling = false;
}
2 Answers
2
Wrong function name
I think I understand the problem. The only reason your ball only jumps once is because the message sent to this script is _OnCollisionStay_ and not _onCollisionStay_; you are just missing a capital O.
function OnCollisionStay (collisionInfo : Collision)
{
isFalling = false;
}
I noticed that you tend to put semicolons after the brackets when declaring a function, which surprises me (I am not an expert on javascript but I am pretty sure this is a mistake (if it isn’t, I hope you’ll forgive me for saying so
) )
if (Input.GetKeyDown(KeyCode. Space) && isFalling == false) // Take out the semicolon at the end ;)
{
GetComponent.<Rigidbody>().velocity.y = jumpHight;
}
I hope this helps!
Thank you so much. I did what you said and now it works. 
I'm very glad it works :) You're welcome! (Could you perhaps accept the answer to mark the question as solved? ;) )
– Quertie