Jump Once?

var jumpH = 8;
var isFalling = false;

function Update () {
	if(Input.GetKey(KeyCode.Space)&& isFalling == false)
	{
		GetComponent.<Rigidbody2D>().velocity.y = jumpH;
		isFalling = true;
	}
}

function OnCollisionStay () {
	isFalling = false;
}

I’m using this script to make my character jump and it works…once. Why only once?

Since “isFalling” is initialized to false, and the only place you set it back to false is in the OnCollisionStay function, I guess the function is note being called.

Debug your code, add a Debug.Log line inside the OnCollisionStay function to make sure it is called. If it’s not called, make sure at least one of the objects colliding has a rigidbody, that they’re not marked as IsKinematic and that the layers of the objects are ticked in the collision matrix of the physics configuration.

Your “OnCollisionStay()” function is behaving exactly as it’s supposed to, and therein lies your problem.

You’re creating the function, rather than using the existing version from Unity’s API. Here is the correct implementation of it.

To be precise, the problem you’re encountering is that you are using:

function OnCollisionStay()

where you need to be using something more like:

function OnCollisionStay(Collision other)

Even if you don’t make use of the other object’s properties passed along during the collision, you still need to include them as a part of the function or it will not match with Unity’s built-in implementation.