- Home /
Unity3d Network - Cant See Connected Players
Hello everyone
i was working on Network Script but i got 1 problem
that the new player cant see the old players
for example :
there is 3 Clients are Connected and Players are Instantiated
the Client1 can See Client 2 and Client 3 Players the Client 2 can see Client 3 Player Client 3 Cant see any players
so only the first Player can see connected People
i'm totally sure that the problem in the way i use to change Level
i use :
void Awake(){
DontDestroyOnLoad(this);
}
void OnServerInitialized(){
Debug.Log("Created! and now go to the map");
Application.LoadLevel(1);
}
void OnPlayerConnected(NetworkPlayer networkPlayer)
{
networkView.RPC("TellPlayerServerName", networkPlayer, serverName);
}
[RPC]
void TellPlayerServerName (string servername)
{
Application.LoadLevel(1);
serverName = servername;
}
//// and now after the map is loaded i call Spawn Function
private void SpawnPlayer(){
Debug.Log("Spawning PlayeR");
Network.Instantiate(Player,new Vector3(0,0,0),Quaternion.identity,0);
}
thats not my full script its just the part of Changing the Scene from MainMenu to Map Scene
Answer by Benproductions1 · Aug 18, 2013 at 11:32 PM
Hello,
Most of the code you have posted is completely irrelevant, however I believe I can predict what you are doing wrong XD
My guess is that you have built your own spawning system.
//my guess is that you have a list of players
List<Player> playerList = new List<Player>()
//then when someone joins (as you already have)
void OnPlayerConnected(NetworkPlayer networkPlayer) {
//you simply iterate through your players and spawn them for the newcomer
foreach (player p in playerList) {
networkView.RPC("SpawnPlayer", networkPlayer, \*etc*\);
}
}
Hope this helps,
Benproductions1
Thanks but Same problem
How I Can Send The Players to one $$anonymous$$ap So they can See Each other
someone told me that i should use prefix
$$anonymous$$y code solves that problem if you implement it correctly. If you don't how can you expect it to work?
"Thanks but Same problem", please elaborate
i think your code would work if i made Game ROO$$anonymous$$
but its not what i need
in my Game One Person Do "Host Game" then he go to the $$anonymous$$ap
then other Player Need to Put IP:Port then Connect
They will be sent to the Same $$anonymous$$ap
but the problem that > New Connect People Cant see Old Connected People
Note that Network.connections
on client will only show the server. That is why I answered the way I did. $$anonymous$$y method works and does exactly what you want. You just have to use it correctly
umm still cant get it
can i put a another Simple Example? :
$$anonymous$$e And 2 $$anonymous$$y Friend are Playing
$$anonymous$$e : Created The Server Then I Have Been Sent To The $$anonymous$$ap
Friend1 : Connected To $$anonymous$$e and He Joined With $$anonymous$$e In The $$anonymous$$ap
Friend2 : Connected To $$anonymous$$e and He Joined With $$anonymous$$e In The $$anonymous$$ap
Now :
$$anonymous$$e Can See Freind1 And Freind2 (i $$anonymous$$ean See The Instantiated Player Prefab)
Friend1 Can Only See Freind2
Friend2 Cannot See Anyone
illation : The Oldest Connected Player Can See The Newest Players But The Newest Cant See The Oldest
Sorry For Bad English
Edit
i Tested Your COde and it worked with me but not in the way i need
u know i let the Connected Players Join together in Room
then They Start Together . your code work fine here
but its not work if there is new player joined
Answer by dc. · Apr 21, 2014 at 08:44 AM
Here is an example, change where needed
networkView.RPC("YourFunction", RPCMode.AllBuffered, VariablesToPassToFunction);
[RPC]
void YourFunction(int Something){
//Do stuff here
}
Your answer
Follow this Question
Related Questions
Problem with network flashlight 1 Answer
Networked level loading 0 Answers
Network Instantiate PlayerPrefab Problem 2 Answers
Buffer RPC until I have the right scene loaded 0 Answers
Network.RemoveRPCs Problem. 1 Answer