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);
}