Just a quickie -
How do I gradually shrink an object?
Couldn’t find on a search
Thanks
Just a quickie -
How do I gradually shrink an object?
Couldn’t find on a search
Thanks
In your update function:
public float targetScale = 0.1f;
public float shrinkSpeed = 0.1f;
cone.transform.localScale = Vector3.Lerp(cone.transform.localScale, new Vector3(targetScale, targetScale, targetScale), Time.deltaTime*shrinkSpeed);
Or alternatively:
public float targetScale = 0.1f;
public float shrinkSpeed = 0.1f;
void Shrink() {
shrinking = true;
}
void Update() {
if (shrinking) {
cone.transform.localScale -= Vector3.one*Time.deltaTime*shrinkSpeed;
if (cone.transform.localScale < targetScale)
shrinking = false;
}
}
Note that while the first option looks quite neat, it will never quite reach your target scale and will keep on adjusting it by a tiny amount forever.