private void OnTriggerEnter(Collider other) { if (other.CompareTag("Player")) { SumoWeight sumoWeight = other.gameObject.GetComponent <SumoWeight>(); if (sumoWeight != null) { switch (_foodType) { case FoodType.healthy: sumoWeight.AddHealthToPlayer(value); FindObjectOfType <FoodManager>().AddSize(value); break; case FoodType.spoiled: sumoWeight.RemoveHealthFromPlayer(value); FindObjectOfType <FoodManager>().RemoveSize(value); break; case FoodType.deadly: sumoWeight.KillPlayer(); break; default: break; } } Destroy(gameObject); } }
private void OnTriggerEnter(Collider other) { if (other.tag == "Player") { SumoWeight sumoWeight = other.gameObject.GetComponent <SumoWeight>(); if (sumoWeight != null) { sumoWeight.KillPlayer(); Destroy(gameObject); } } }