Hi, I have a project in which the user is allowed to change the rotation and scaling of an object. When the object is "released", a coroutine should smoothly reset the object to it's original scale and rotation. The problem I am having is that the rotation reset works, but not the scaling. Does anybody know why that happens? Thanks, Paul This is my code: Code (CSharp): float counter = 0f; while (counter < 1) { currentProduct.transform.localScale = Vector3.Lerp(sca, originalScale, counter); rotateTransform.transform.localRotation = Quaternion.Slerp(rot2, originalRotationValue, counter); currentProduct.transform.localRotation = Quaternion.Slerp(rot1, originalRotationValue, counter); currentProduct.position = Vector3.Lerp(pos, originalPosition, counter); counter += Time.deltaTime / state0duration; yield return null; }
Check the values that are applied to the localScale. E.g. breakpoint @ 6 / print those sca and originalScale. Maybe they're not what you're expecting. Also, make sure that scaling is not changed somewhere else.
didn't test this code, but this is what I used: Code (CSharp): float elapsedTime = 0; Vector3 startScale = new Vector3(0f,0f,0f); Vector3 targetScale = new Vector3(1f,1f,1f); card.transform.localScale = startScale; float timeTakes = 1f // animation will take one second while (elapsedTime < timeTakes) { card.localScale = Vector3.Lerp(card.transform.localScale, targetScale, (elapsedTime / timeTakes)); elapsedTime += Time.deltaTime; yield return new WaitForEndOfFrame(); }