2017-02-18 65 views
0

所有玩家的位置,我想知道如何讓網絡中的所有可用的球員的位置。 那麼如何更新我的腳本?如何獲得光子

using UnityEngine; 
using System.Collections; 
using System.Collections.Generic; 
public class Pathfinding : MonoBehaviour { 
Transform[] Players; 
int TotalPlayerCount=0; 
void Update() { 
    foreach (PhotonPlayer pl in PhotonNetwork.playerList) { 
     if (GetComponent<PhotonView>().isMine) { 
      Players[TotalPlayerCount].position= //position of my player 
      TotalPlayerCount++; 
     } 
     else 
     { 
      Players[TotalPlayerCount].position=//position of all other player available in the room 
      TotalPlayerCount++; 
     } 
    } 
} 

回答

0

每個客戶甚至可以在一個房間裏是之前SetCustomProperties設置它的玩家的自定義屬性。他們在加入房間時同步。

Hashtable xyPos = new Hashtable(); 
xyPos.Add(1, "10"); 
xyPos.Add(2, "-20"); 
PhotonPlayer.SetCustomProperties(xyPos, null, true) ; 

對於進一步的閱讀,你應該嘗試下面的教程(它會給你更強的想法如何獲得和同步位置): http://doc.photonengine.com/en/pun/current/tutorials/tutorial-marco-polo#_Toc317517599