Jump with mathf.lerp problem

Hello,

i want my player to jump using mathf.Lerp.

I already managed to make him jump, but he doesn’t fall again. What’s wrong with my script?

function Update () {
	
	transform.Rotate(0,0,Input.GetAxis("Horizontal") * speed * Time.deltaTime);
	player.transform.localPosition.y = newPos;
	if(Input.GetKeyDown(KeyCode.Space))
	{
		jumping = true;
	}
	if(jumping)
	{
		Jumper();
	}
}

function Jumper () {
	timer += Time.deltaTime * jumpSpeed;
	timerFall += Time.deltaTime * jumpSpeed;
	newPos = new Mathf.Lerp(startPos, startPos + jumpHeight, timer * jumpSpeed);
	yield WaitForSeconds(0.5);
	newPos = new Mathf.Lerp(startPos + jumpHeight, startPos, timerFall * jumpSpeed);
}

you don’t cancel the jumping by setting the jumping = false;

instead of if check, just use this:

jumping = Input.GetKeyDown(KeyCode.Space);

this will set it true or false according to space key.

Ok, this is a really old post, and you’ve probably already figured it out by now, but since you are using:
yield WaitForSeconds(0.5);
Shouldn’t your Function be written as:
function Jumper() : IEnumerator {

}
and your Function call as:
if(jumping)
{
StartCoroutine(Jumper());
}
???