First Lerp() takes two Vector3 parameters and a fraction parameter. You are passing three floats. Assuming you are doing this to size over time, ‘Explosion’ would need to get called every frame. I doubt you have it structured that way. You can structure Explosion as a coroutine to make this work. Here is a bit of demo code. Create a new scene, Create a cube, add this code to the cube. While running the up and down arrow keys will make the cube bigger or smaller.
#pragma strict
public var scaleBy : float = 1.5;
public var speed : float = 1.0;
private var scale : Vector3 = Vector3(1,1,1);
private var scaling = false;
private var trans : Transform;
function Start() {
trans = transform;
}
function Update() {
if (!scaling) {
if (Input.GetKeyDown(KeyCode.UpArrow)) {
Explosion(scaleBy, speed);
}
else if (Input.GetKeyDown(KeyCode.DownArrow)) {
Explosion(1.0 / scaleBy, speed);
}
}
}
function Explosion(factor : float, speed : float) {
scaling = true;
scale *= factor;
while (trans.localScale != scale) {
trans.localScale = Vector3.MoveTowards(trans.localScale, scale, Time.deltaTime * speed);
yield;
}
scaling = false;
}
The ‘scaling’ boolean variable is used to lock out input while the cube is scaling. You may not need it for an explosion use.