- Home /
connect to hosted level
Hello! So im experiencing with networking in unity. I have two scenes in my project, a main menu and a level1. In the main menu when you set up a server i execute the next few lines of code
if(GUI.Button(Rect(100,250,200,50), "Start server"))
{
PlayerPrefs.SetString("ServerName", serverName);
Network.InitializeServer(numberOfPlayers,serverPort, false);
PlayerPrefs.SetInt("SelectedLevel", 1);
Application.LoadLevel(PlayerPrefs.GetInt("SelectedLevel"));
}
So in this case i am the host and i load the level perfectly fine.
In the loaded level (level1) i have a game object with a network managging script wich managges two things : a GUI menu where you can select your Character and instantiate it with a button press with Network.Insantiate()
and send an RPC to the connected palyers to load the same level, here is the code snipet :
function OnPlayerConnected (networkpalyer : NetworkPlayer)
{
networkView.RPC("SendLevel", RPCMode.OthersBuffered ,PlayerPrefs.GetInt("SelectedLevel"));
}
@RPC
function SendLevel (level : int)
{
Application.LoadLevel(level);
}
It works fine, the connected Client is loaded the same level as expected. On the host side i can move around and see the connected player also moving around but on the client side i can only see the loaded level and my self and i cant see the player who hosted the game.
I have no clue how to solve this problem, its like the client is connected to a nother server but we are on the same server and the host can see both players and also interact whit the other player, like i can push him around but this movement doesnt seen on the Client side. Any ideas?
How this thing is usually done?
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Loadlevel can't see each other. 2 Answers
Number of scenes for iPhone games 1 Answer
Network instantiate problem 1 Answer
Network - Changing Scenes Errors 0 Answers