This script is attached to the object I want to scale to 0,0,0 It's just not doing anything to the object it's attached to. No errors or exceptions just does nothing.
The maxSize in this case is 4,3,0.2 The minSize is 0,0,0
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Scale : MonoBehaviour
{
public GameObject objectToScale;
public float duration = 1f;
public Vector3 minSize;
public Vector3 maxSize;
public bool scaleUp = false;
public Coroutine scaleCoroutine;
public bool scalingHasFinished = false;
private void Start()
{
objectToScale.transform.localScale = maxSize;
scaleOverTime();
}
private void Update()
{
}
public IEnumerator scaleOverTime()
{
float counter = 0;
Vector3 startScaleSize = objectToScale.transform.localScale;
while (counter < duration)
{
counter += Time.deltaTime;
objectToScale.transform.localScale = Vector3.Lerp(startScaleSize, minSize, counter / duration);
yield return new WaitForSeconds(duration);
}
scalingHasFinished = true;
}
}
The main goal is to squeeze the object from all size to 0,0,0 like a magic effect making the object disappear slowly.