I have a chest that I applied a script to, I’m trying to make objects start small while in the chest and as they’re popping out of the chest get to regular scale. This is part of the script that I just added:
GameObject justDropped;
float newScale = Mathf.Lerp(1, 5, Time.time / 5);
if (randomValue <= LootTable[j].dropRarity)
{
Vector3 direction = new Vector3(Random.Range(1, 3), 3, Random.Range(-2, 2));
justDropped = Instantiate(LootTable[j].item, transform.position, Quaternion.identity);
justDropped.GetComponent<Rigidbody>().AddForce(direction * Random.Range(50, 100));
justDropped.transform.localScale += new Vector3(newScale, newScale, newScale);
return; //remove this for more items
I get gameobjects with scales that are 1 , 1 , 1 as giant items and they don’t transform over time, and for some items who have scale that is more than 1, 1, 1 just come out normal size.