I have an integer that updates itself from 0 - 599 which I'm trying to normalize and pass to another variable. My first integer value is just a single int. It isn't in a list or anything.
What I'm trying to do is tie in a color lerp time length based on the length of integer value. This integer value is iterating through a list of meshes to be displayed. It looks like this:
int meshNum;
public void AnimateMesh()
{
if(playAnim)
{
meshToChange.GetComponent<MeshFilter>().mesh = fluidMesh[meshNum];
if(meshNum < 599)
meshNum++;
else
meshNum = 0;
}
else
{
meshNum = 0;
}
}
And my lerp code for the color is this:
diffuse_Material.color = Color.Lerp(Color.blue, Color.red, speedCount);
What I'm wanting to change speedCount in my lerp method to a variable that is matched with the length of the animation. My lerp isn't always on screen, but the animation is, when I want the lerp to appear, I want to it be the same each time it appears no matter where the animation currently is.
Color.Lerp
expects a parameter from 0 .. 1
. The simplest way would be to simply give it (float)meshNum / 599f
.