using System.Collections; using System.Collections.Generic; using UnityEngine; public class SprayScript : MonoBehaviour { private int wiped = 0; Color tmp; void OnTriggerExit2D(Collider2D other){ tmp = this.GetComponent().color; if(other.gameObject.name == "Rag") { wiped++; tmp.a -= 0.15f; this.GetComponent().color = tmp; if(wiped >= 3) Destroy(this.gameObject); } } }