using System.Collections; using System.Collections.Generic; using UnityEngine; public class WaypointScript : MonoBehaviour { public float life; // Start is called before the first frame update void Start() { StartCoroutine(CoUpdate()); } IEnumerator CoUpdate() { float t = 0; while (true) { Color c = this.gameObject.GetComponent().color; c.a *= 0.99f; this.gameObject.GetComponent().color = c; this.transform.localScale *= 1.002f; t+= Time.deltaTime; if(t > life) { Destroy(this.gameObject); yield break; } yield return null; } } }