I'm trying to scale an object gradually along the Y axis until it's the same size as another gameobject, or I could enter the dimensions manually. Right now I have this.
growScale = ObjectToScale.transform.localScale;
targetSize = TargetObject.GetComponent<RectTransform>().localScale;
isScale = true;
void Update()
{
if (isScaleCurtainBottomEasyRead)
{
growScale += new Vector3(0, 1, 0) * 0.01f;
ObjectToScale.transform.localScale = Vector3.Lerp(ObjectToScale.transform.localScale, growScale, 0.5f);
if (ObjectToScale.transform.localScale == targetSize)
{
isScaleCurtainBottomEasyRead = false;
}
}
}
The object never stops scaling. I assume that's because it never gets to the exact same size and is slightly over or under, but I can't figure out how to stop it from scaling. I'm willing to enter the dimensions manually instead of using TargetObject as a reference for the size it should be, but everything I can find online talks about scaling indefinitely or using a bool to stop it rather than when it reaches a certain size. How can I solve this?
Edit: Programmer marked this as a duplicate, but the linked question asks how to scale the object for a certain period of time. I need to scale it until it reaches a specific size, not for a certain number of seconds.