using UnityEngine; public class footPrintFadingDestroy : MonoBehaviour { public float timeFading = 5f; private Material footMat; private Color _color; private void Start() { footMat = GetComponent().material; _color = footMat.GetColor("_Color"); } private void FixedUpdate() { timeFading = Mathf.MoveTowards(timeFading, 0f, Time.fixedDeltaTime); if (timeFading == 0f) { _color.a = Mathf.MoveTowards(_color.a, 0f, Time.fixedDeltaTime * 0.1f); footMat.SetColor("_Color", _color); } if (_color.a == 0f) { Object.Destroy(base.gameObject); } } }