- Home /
Question by
aqib-nawaz-003 · Nov 02, 2017 at 05:13 AM ·
unity 5multiplayer-networkingunity 4
finding other network player unity unet
I am having problem in getting other network player. I want to store like this.
void Start ()
{
GameObject[] players = GameObject.FindGameObjectsWithTag ("Player");
for (int i = 0; i < players.Length; i++) {
if (players [i].GetComponent <NetworkIdentity> ().isLocalPlayer) {
minePlayer = players [i];
}
if (!players [i].GetComponent <NetworkIdentity> ().isLocalPlayer) {
oppenentPlayer = players [i];
}
}
}
in server I only find mine player and in other network player i find both but not correctly. Advance thanks for your help :)
Comment
@x4637x @Bunny83 @unitynoob @omerselman Sorry for mentioning you.
kindly help me about this issue
What do you mean by "I find both but not correctly"?
I see nothing wrong in your code (except the fact that you could just do "else" ins$$anonymous$$d of doing a second GetComponent, which is going to weight on your performance)
Dear @jeango Thanks for the help. I used else then in one player i found onle $$anonymous$$e player and in other player i found both correctly.