2017-02-18 4 views
0

ネットワーク内のすべてのプレイヤーの位置を取得する方法を知りたい。 スクリプトを更新するにはどうしたらいいですか?Photonのすべてのプレイヤーの位置を取得する方法

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

関連する問題