0
개체의 트리거 영역에 입장하면 메시지 (플레이어가 태그로 찾음)가 표시됩니다. 플레이어가 픽업 버튼을 누르면 항목이 인벤토리에 추가됩니다. 그것은 싱글 플레이어 게임에서 잘 작동합니다.Photon Unity Networking을 사용하여 네트워크 게임의 특정 플레이어에게 메시지 표시
PUN (Photon Networking)을 사용할 때 (모든 플레이어의 스크립트에서 이벤트를 감지하므로) 모든 플레이어에게 표시되지만 모든 플레이어가 항목을 가져올 수 있습니다. 이 문제를 어떻게 해결할 수 있습니까?
void OnTriggerEnter(Collider col)
{
if (col.gameObject.tag == "Player")
{
displayMessage = true;
}
}
void OnTriggerExit(Collider col)
{
if (col.gameObject.tag == "Player")
{
displayMessage = false;
}
}
bool stop = false;
void OnGUI()
{
if (displayMessage)
{
if (GameObject.FindGameObjectWithTag("UInventory").GetComponent<UInventory>().inventoryMode == "Weight")
{
GUI.Label(new Rect((Screen.width/2)-200, (Screen.height/2)-30, 200, 45), "Press " + pickUpItem.ToString() + " To Take " + itemName + "(" + itemWeight + "kg)");
}
else
{
GUI.Label(new Rect((Screen.width/2)-200, (Screen.height/2)-30, 200, 45), "Press " + pickUpItem.ToString() + " To Take " + itemName);
}
}
}