์•„์ดํ…œ ์ฃผ์šฐ๋ฉด ํ…์ŠคํŠธ๊ฐ€ ๋‚จ์•„์žˆ๋Š”๋ฐ ์–ด์ผ€ํ•ฉ๋‹ˆ๊นŒ์—ฌ?


public class PickUpItem : MonoBehaviour { public GameObject ItemOB; public GameObject invOB; public GameObject pickUpText; public AudioSource keySound; public bool inReach; // Start is called before the first frame update void Start() { inReach = false; pickUpText.SetActive(false); invOB.SetActive(false); } void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Reach") { inReach = true; pickUpText.SetActive(true); } } void OnTriggerExit(Collider other) { if (other.gameObject.tag == "Reach") { inReach = false; pickUpText.SetActive(false); } } // Update is called once per frame void Update() { if (inReach && Input.GetButtonDown("Interact")) { ItemOB.SetActive(false); keySound.Play(); invOB.SetActive(true); pickUpText.SetActive(false); } } }