Search Unity

Fading Trail

Discussion in 'General Graphics' started by SGiygas, Mar 14, 2017.

  1. SGiygas

    SGiygas

    Joined:
    Jan 18, 2017
    Posts:
    6
    I've been trying to make a Trail Renderer fade away for a while now but no solution I've found so far seems to work. I've tried modifying the material color, the start and end color and even the alpha itself but nothing seems to work. Is there even a way to make a trail fade away (I might just not see a stupid mistake)? Please help me. Thanks in advance.

    Here's my current setup:
    Code (CSharp):
    1.     public TrailRenderer trail;
    2.     Color colorDef;
    3.     Color colorTemp;
    4.  
    5.     void Start () {
    6.         colorDef = trail.material.color;
    7.         colorTemp = trail.material.color;
    8.         colorTemp.a -= 0.1f;
    9.     }
    10.  
    11.     public void fadeTrail()
    12.     {
    13.         while(trail.material.color != colorTemp)
    14.         {
    15.             if (colorTemp.a > 0)
    16.             {
    17.                 colorTemp.a -= 0.1f;
    18.             }
    19.             trail.material.color = colorTemp;
    20.         }
    21.     }
     
    Last edited: Mar 14, 2017
  2. v73v3

    v73v3

    Joined:
    Aug 22, 2017
    Posts:
    1
    Try:

    Code (CSharp):
    1. trail.material.SetColor("_TintColor", colorTemp);
    Your trail material shader will need the TintColor property, obviously.

    (Yes this is a necro but I Googled in circles for far too long to find this answer. Hoping to save others the same fate)