Mathf.Lerp skips numbers

I have a very simple, virtually empty scene, so lagging isn’t a reason, but when using Mathf.Lerp as follows:

	if(Input.GetKeyDown("space")){
		grow = true;
	}
	if(grow){
		size = Mathf.Lerp(40.0, 100.0, growthSpeed*Time.time);
		
	}

It skips between 10 and 20 straight away! rather than starting from 40 and counting up it starts immediately between 50 and 60 then continues counting slowly! (growthSpeed is 0.1) and size starts at 40. I don’t understand why it’s skipping like this! Any ideas?

thanks in advance!

Your results will vary depending on how quickly you hit the space bar. The third parameter of a Lerp() needs to be in the range of 0.0, and 1.0. So here is an alternate solution.

Set your ‘growthSpeed’ to 1.0, initialize size to 40.0, then change line 5 to:

 size = Mathf.MoveTowards(size, 100.0, growthSpeed*Time.deltaTime);

‘growthSpeed’ will now be units per second.