void MyShpere() { height2 = (float)CustomScaler.Scale(height, 0, 10, leftPosition, rightPosition); rotationAmount += height2 * Time.deltaTime; timePassed += Time.deltaTime; if (Input.GetKeyDown(KeyCode.RightArrow)) { timePassed = 0f; resetTime = false; startPosition = rotationAmount; if (rotationAmount != 0f) { isCentered = false; duration = shorterDuration; } } if (Input.GetKey(KeyCode.RightArrow)) { endPosition = rightPosition; } if (Input.GetKeyUp(KeyCode.RightArrow)) { resetTime = true; endPosition = 0; startPosition = 0; } if (Input.GetKeyDown(KeyCode.LeftArrow)) { timePassed = 0f; resetTime = false; startPosition = rotationAmount; if (rotationAmount != 0f) { isCentered = false; duration = shorterDuration; } } if (Input.GetKey(KeyCode.LeftArrow)) { endPosition = leftPosition; } if (Input.GetKeyUp(KeyCode.LeftArrow)) { resetTime = true; endPosition = 0; startPosition = 0; } change = endPosition - startPosition; if (timePassed <= duration && !resetTime) { if (!isCentered) { rotationAmount = TweenManager.EaseInQuad(timePassed, startPosition, change, duration); } if (isCentered) { rotationAmount = TweenManager.EaseInExpo(timePassed, startPosition, change, duration); } } if (timePassed >= duration || resetTime) { if (rotationAmount > 0f) { rotationAmount -= Time.deltaTime * 1f; } if (rotationAmount < 0f) { rotationAmount += Time.deltaTime * 1f; } if (rotationAmount > -0.1f && rotationAmount < 0.1f) { timePassed = 0f; resetTime = false; isCentered = true; duration = intitialDuration; } } }