Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    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?