Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class FoodEat : MonoBehaviour
- {
- public GameObject FoodGO;
- public Rigidbody FoodRB;
- private void OnTriggerEnter(Collider Creature)
- {
- Destroy(FoodGO);
- }
- void Start()
- {
- FoodRB = GetComponent<Rigidbody>();
- FoodGO = FoodRB.gameObject;
- }
- void Update()
- {
- Rigidbody[] allRigidBodies = (Rigidbody[])FindObjectsOfType(typeof(Rigidbody));
- foreach (Rigidbody body in allRigidBodies)
- {
- if (body.gameObject.layer == 10)
- {
- OnTriggerEnter(body.gameObject.GetComponent<CapsuleCollider>());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement