IEnumerator SlideObject(LerpPackage _input) { bool _isMovingClipboard = false; if (_input.go == this.gameObject) // special case for moving clipboard { _isMovingClipboard = true; } if (_isMovingClipboard) { isInMotion = true; } float progress = 0.0f; Vector3 startingPos = _input.posStart; Vector3 targetPos = _input.posEnd; Vector3 startingRot = _input.rotStart; Vector3 targetRot = _input.rotEnd; Vector3 startingScale = _input.scaleStart; Vector3 targetScale = _input.scaleEnd; // early out if the object is already basically there if (Vector3.Distance(_input.go.transform.position, targetPos) < 0.1f) { _input.go.transform.localPosition = targetPos; } else { while (progress < 1.0f) { // lerp in local position _input.go.transform.localPosition = Vector3.Lerp(startingPos, targetPos, Lerp_FastInEaseOut(progress)); _input.go.transform.localEulerAngles = Vector3.Lerp(startingRot, targetRot, Lerp_FastInEaseOut(progress)); _input.go.transform.localScale = Vector3.Lerp(startingScale, targetScale, Lerp_FastInEaseOut(progress)); progress += Time.deltaTime * lerpSpeed; yield return(null); } // make sure it makes it all the way down _input.go.transform.localPosition = targetPos; _input.go.transform.eulerAngles = targetRot; _input.go.transform.localScale = targetScale; } if (_isMovingClipboard) { isInMotion = false; } }
IEnumerator SlideObject(LerpPackage _input) { bool _isMovingClipboard = false; if (_input.go == this.gameObject) // special case for moving clipboard { _isMovingClipboard = true; } if (_isMovingClipboard) { isInMotion = true; } float progress = 0.0f; Vector3 startingPos = _input.posStart; Vector3 targetPos = _input.posEnd; Vector3 startingRot = _input.rotStart; Vector3 targetRot = _input.rotEnd; Vector3 startingScale = _input.scaleStart; Vector3 targetScale = _input.scaleEnd; // early out if the object is already basically there if (Vector3.Distance(_input.go.transform.position, targetPos) < 0.1f) { _input.go.transform.localPosition = targetPos; } else { while (progress < 1.0f) { // lerp in local position _input.go.transform.localPosition = Vector3.Lerp(startingPos, targetPos, Lerp_FastInEaseOut(progress)); _input.go.transform.localEulerAngles = Vector3.Lerp(startingRot, targetRot, Lerp_FastInEaseOut(progress)); _input.go.transform.localScale = Vector3.Lerp(startingScale, targetScale, Lerp_FastInEaseOut(progress)); progress += Time.deltaTime * lerpSpeed; yield return null; } // make sure it makes it all the way down _input.go.transform.localPosition = targetPos; _input.go.transform.eulerAngles = targetRot; _input.go.transform.localScale = targetScale; } if (_isMovingClipboard) { isInMotion = false; } }