Question by
shadowkiller0071 · Apr 27, 2016 at 05:23 AM ·
javascriptcoroutinesinterpolationmathf.lerp
Trying to use coroutines in order to use Mathf.Lerp, Lerp instantly jumps values
What am I doing wrong?
function scalePlayer(scaleTo : float, timeUp : float, timeDown : float) {
StopCoroutine("scaleTo");
StopCoroutine("scaleBack");
StartCoroutine(scaleTo(scaleTo, timeUp));
yield WaitForSeconds(timeUp);
StartCoroutine(scaleBack(scaleTo, timeDown));
}
function scaleTo(scaleTo : float, timeUp : float) {
player.transform.localScale = new Vector3(Mathf.Lerp(objectScale[0], scaleTo, Time.deltaTime/timeUp), Mathf.Lerp(objectScale[1], scaleTo, Time.deltaTime/timeUp), 0);
yield;
}
function scaleBack(scaleTo : float, timeDown : float) {
player.transform.localScale = new Vector3(Mathf.Lerp(scaleTo, objectScale[0], Time.deltaTime/timeDown), Mathf.Lerp(scaleTo, objectScale[1], Time.deltaTime/timeDown), 0);
yield;
}
Comment
Your answer
Follow this Question
Related Questions
Mathf.Lerp for integers 1 Answer
Using Couroutines in another Class (Javascript) 0 Answers
Lerp is instant. How to fix? 2 Answers
About UnityScript - us.exe compiler 0 Answers