Для моей автомобильной военной войны я получил метки заноса, когда машина поворачивает.Он работает правильно, теперь, через несколько секунд, я хочу уменьшить его альфа и удалить его из игры.Я использовал Trail Renderer для генерации отметок заноса.
- Какой шейдер мне нужен для назначения материала?
- , каким образом я могу уменьшить его альфа?
В настоящее время я использовал такой материал для рендеринга следов:

Теперь для постепенного уменьшения альфа у меня есть такой код:
private IEnumerator Start()
{
Material myMaterial = GetComponent<Renderer>().material;
while (true)
{
yield return new WaitForSeconds(1f);
// check whether this skid trail has finished
// (the Wheel script sets the parent to null when the skid finishes)
if (transform.parent.name == "SkidTrailsDetachedParent")
{
// set the start colour
//Color startCol = GetComponent<Renderer>().material.color;
//Color startCol = myMaterial.GetColor("_EmisColor");
Color startCol = myMaterial.GetColor("_TintColor");
// wait for the persist time
yield return new WaitForSeconds(persistTime);
float t = Time.time;
// fade out the skid mark
while (Time.time < t + fadeDuration)
{
float i = Mathf.InverseLerp(t, t + fadeDuration, Time.time);
//myMaterial.color = startCol * new Color(1, 1, 1, 1 - i);
//myMaterial.SetColor("_EmisColor", startCol * new Color(1f, 1f, 1f, 1f - i));
myMaterial.SetColor("_TintColor", startCol * new Color(1f, 1f, 1f, 1f - i));
yield return null;
}
// the object has faded and is now done so destroy it
Destroy(gameObject);
}
}
}
Тем не менее, это не работает для меня.