// Update is called once per frame void Update() { Vector3 targetPos = manager.GetLanePosition(laneIndex, playerIndex); if (!jumping) { if (Input.GetKeyDown(GetLeft)) { laneIndex -= 1; } if (Input.GetKeyDown(GetRight)) { laneIndex += 1; } if (Input.GetKeyDown(GetJump)) { jumping = true; JumpTimer = JumpTime; animator.SetTrigger(JUMP); } } else if (jumping) { if (JumpTimer > 0.1f) { if (JumpTimer < (JumpTime - 0.25f)) { targetPos.y = jumpHeight; } JumpTimer -= Time.deltaTime; } else { targetPos.y = startY; jumping = false; } } laneIndex = Mathf.Clamp(laneIndex, 0, manager.Lanes.Length - 1); transform.position = Vector3.Lerp(transform.position, targetPos, lerpSpeed); }