darkhog
1
I have some variables that I’d like to linearly twine from one value to another over specific amount of time. How do I do that?
Use the Lerp function in Mathf: Unity - Scripting API: Mathf.Lerp
You might also look at doing this in a Coroutine instead of Update so that once you reach your target value you can just exit.
var value :float;
var periodLength :int; //Seconds
var amount :float; //Amount to add
function Update()
{
value = Mathf.Floor(Time.time * periodLength) * amount;
}
This is untested. Just try out. If this shouldn’t work, then just look for Coroutine at the Unity Script Reference.