Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

Lerp is instant. How to fix?

$
0
0
I'm trying to interpolate a float value from one value to another value over a time. These 3 are parameters for the function containing the Lerp. Here is the code. //Function to scale player up and down function scalePlayer(scaleTo : float, timeUp : float, timeDown : float) { player.transform.localScale = new Vector3(Mathf.Lerp(objectScale[0], scaleTo, Time.deltaTime/timeUp), Mathf.Lerp(objectScale[1], scaleTo, Time.deltaTime/timeUp), 0); yield WaitForSeconds(timeUp); player.transform.localScale = new Vector3(Mathf.Lerp(scaleTo, objectScale[0], Time.deltaTime/timeDown), Mathf.Lerp(scaleTo, objectScale[1], Time.deltaTime/timeDown), 0); } I've looked through all online resources and can't find anything that fixes the problem. The array being used is one that stores the players original size. The first Lerp interpolates the players scale between their starting scale and their new scale, the second one scales them back. The game is rhythm based so I want the players size to change with the beat. The value jumps up instantly when the function is called and the second part after the waitforseconds is never even called. What am I doing wrong?

Viewing all articles
Browse latest Browse all 1875

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>