enlarging an object then destroying it

Hello All,

So I am trying to make an instantiated game object grow to a predetermined size ( or for a predetermined time ) and then disappear. Much like a balloon inflating and then popping. The code I have is obviously wrong because it isn’t working. Her is what I have:

maxSize = 5.0;

growthRate = 1.0;

scale = 1.0;

function Update () {

transform.localScale = Vector3.one * scale;

scale += growthRate * Time.deltaTime;

if (scale > maxSize) Destroy (gameObject);

}

Any help at all would be greatly appreciated.

Thanks
-Rich

You just need to declare your variable types:

var maxSize : float = 5.0;
var growthRate : float = 1.0;
var scale : float = 1.0;

function Update () 
{
   	transform.localScale = Vector3.one * scale;
    scale += growthRate * Time.deltaTime;
    if (scale > maxSize) Destroy (gameObject);
}