void OnTriggerEnter(Collider other) { // If the entering collider is the food... if (other.gameObject.CompareTag("Food") && other is SphereCollider) { // ... the food detected. //print("Food in detection field: "+Vector3.Distance(gameObject.transform.position, other.gameObject.transform.position)); foragerMemory.UpdateFoodInfo(other.gameObject.GetComponent <Food>().info); } }
void Collect() { // Reset the timer. timer = 0f; // If the food has food to collect... if (food != null && foodAmount.currentAmount > 0) { // ... collect the food. collectAmount = Mathf.Min(foodAmount.currentAmount, ForagerCapacity.maxCapacity - foragerCapacity.currentCapacity, collectAmount); foodAmount.BeCollected(collectAmount); foragerCapacity.AddFood(collectAmount); } foragerMemory.UpdateFoodInfo(food.GetComponent <Food>().info); }