I want to know how to get the position of all available player in the network. So how can I update my script ?
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++;
}
}
}
Each client can set it's player's custom properties with SetCustomProperties, even before being in a room. They are synced when joining a room.
Hashtable xyPos = new Hashtable();
xyPos.Add(1, "10");
xyPos.Add(2, "-20");
PhotonPlayer.SetCustomProperties(xyPos, null, true) ;
For further reading, you should try following tutorial(It will give you a stronger idea how to get and sync positions): http://doc.photonengine.com/en/pun/current/tutorials/tutorial-marco-polo#_Toc317517599