using System.Collections; using System.Collections.Generic; using UnityEngine; public class Collition : MonoBehaviour { [SerializeField] Color32 hasPackageColor = new Color32(1,1,1,1); [SerializeField] Color32 noPackageColor = new Color32(1,1,1,1); [SerializeField] float DestroyDelay = 0.5f; bool hasPackage; SpriteRenderer spriteRenderer; void Start() { spriteRenderer = GetComponent(); } void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Package" && !hasPackage) { Debug.Log("Package"); hasPackage = true; spriteRenderer.color = hasPackageColor; Destroy(other.gameObject, DestroyDelay); } if (other.tag == "Customer" && hasPackage) { Debug.Log("Customer"); hasPackage = false; spriteRenderer.color = noPackageColor; } } // void OnTriggerExit2D(Collider2D other){ // } }