unity3d - Display a message to a specific player in a networked game using Photon Unity Networking -
on entering trigger zone of object message displayed player (which found tag). if player presses pickup button, item added inventory. works fine in single-player games.
when utilize pun (photon networking) though displays players (as player's script observe event) , players can pickup item. how can prepare problem?
i believe fixing piece enable me understand how prepare else:
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() + " take " + itemname + "(" + itemweight + "kg)"); } else { gui.label(new rect((screen.width/2)-200, (screen.height/2)-30, 200, 45), "press " + pickupitem.tostring() + " take " + itemname); } } }
trigger code should executed if client owns network object. utilize 'ismine' property of 'photonview' component of object check if true.
networking unity3d photon
No comments:
Post a Comment