/// <summary> /// Moves the player from the current position to the end position. /// Parameters: Vault speed, will the player climb on top of the object? and the end position. /// </summary> private IEnumerator Vault(float speed, bool climb, Vector3 endPosition) { // Locks the player so it can not move. controller.isClimbing = true; float t = 0.0f; // Movement progress. Vector3 start = transform.position; Vector3 end = transform.position + (transform.up * endPosition.y) + (transform.forward * endPosition.z); cameraAnimations.PlayParkourAnimation(); // Play vault animation on camera. weaponManager.Vault(climb); // Play vault animation on the current weapon. while (t < 1.0f) { t += Time.deltaTime * speed; // Increase movement progress. transform.position = Vector3.Lerp(start, end, t); // Moves the player from the current position to the end position. yield return(null); } controller.isClimbing = false; }