Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Animate from a color back to the original color.

Discussion in 'Animation' started by Deleted User, Apr 21, 2022.

  1. Deleted User

    Deleted User

    Guest

    The behavior I'm trying to get out of Unity's Animator looks like this in code:

    Code (CSharp):
    1. Color animationColor = Color.red;
    2. Color originalColor = GetComponent<Renderer>().material.GetColor("_Color");
    3. //...
    4. renderer.material.SetColor("_Color", Color.Lerp(animationColor, originalColor, timeElapsed/animationTime));
    I have no problem getting the animator to Lerp between two set colors, but I would like to have destination color be the original color of the object. Can this be done with the Animation system?