- Home /
Question by
galshal · Jun 02, 2015 at 05:15 PM ·
networkingphoton
photon players position
hi guys im trying to create a radar for my photon network game, the thing is that i need to get the position of every player's object in the room,
does it have any way to get all players position?
thanks in advance
Gal
Comment
Answer by 334499p · Jul 17, 2015 at 10:53 PM
As long as you're scripts properly sync player positions then this topic has a simple local-side solution.
GameObject[] players;
Void Start(){
StartCoroutine(getPlayers());
}
IEnumerable getPlayers(){
While (true){
players = GameObject.FindObjectsWithTag("Player");
yield return new WaitForSeconds(2f);
}
}
Void Update(){
Foreach (GameObject p in players){
If (p != null){
// do something with p's position
}
}
}
Make sure that all player tags are set to "Player." The coroutine will update the player gameobjects every 2 seconds to reduce lag.
Your answer