using StarterAssets; using System.Collections; using System.Collections.Generic; using UnityEngine; public class TakeItem : MonoBehaviour { public GameObject ui; public GameObject box; public GameObject bag; public GameObject Player; private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Player") { ui.SetActive(true); } } private void OnTriggerExit(Collider other) { if (other.gameObject.tag == "Player") { ui.SetActive(false); box.SetActive(false); } } private void OnTriggerStay(Collider other) { if(Input.GetKeyDown(KeyCode.E)) { box.SetActive(!box.activeInHierarchy); if(box.activeInHierarchy) { bag.SetActive(true); } } } }