[๐ฃ์ง๋ฌธ]
์ฝ๋ ์ง๋ฌธ์
์ต๋ช
(183.102)
2022-07-29 23:40
์ถ์ฒ 0
์์ดํ
์ฃผ์ฐ๋ฉด ํ
์คํธ๊ฐ ๋จ์์๋๋ฐ ์ด์ผํฉ๋๊น์ฌ?
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);
}
}
}
๋ชฐ?๋ฃจ / ๋ง์ฝ ItemOB๋ ํ ์คํธ๋ ์ฐ๊ด๋์ด ์๋ค๋ฉด ์ ๋ฐ์ดํธ์ ์กฐ๊ฑด๋ฌธ์์ ์์๋ฌธ์ ์ผ์๋?
Update์์ ์์ดํ ์ฃผ์ ์๋ ์ฝ๋๊ฐ ์คํ๋ฌ์ผ๋ฉด pickUpText๊ฐ false๊ฐ ๋ฌ์ํ ๋ฐ ๋ฌด์จ ์ฐ์ ๋ก true๊ฐ ๋๊ฑฐ๊ฐ์๋ฐ. ๊ทธ๊ฑธ ์ถ์ ํด๋ด. ์ ์ฝ๋๋ง๊ฐ์ง๊ณ ๋ ์์๊ฐ ์์.
ใ ใ ๊ฐ์ผ๋ค