Hi!.
I’m very new at networking and I’m trying to make my first multiplayer game.
What I wanna do is a version of my single player where theclient is playing and the server can control some factors of the client’s game in real time.
I’ve based on the tutorial of the official site named:“MultiplayerTutorial”.
What I want is that in the initial menu where I choose the type of connection and then if I’m the server or not, (and the same for the client’s version) each one goes to one different level: client version starts to play the game and server’s version starts in a different level, where he receives the “in progress” game and has some buttons where to control some aspects of the client game.
If found with some troubles:
a).-How to deal with the different scene/level for both “players”: server and client.
function OnGUI ()
{
// When network is running (server or client) then display the level “StarTrooper”
if (Network.peerType != NetworkPeerType.Disconnected)
{
if (GUI.Button(new Rect(350,10,100,30),“juega”))
{
// Make sure no old RPC calls are buffered and then send load level command
Network.RemoveRPCsInGroup(0);
Network.RemoveRPCsInGroup(1);
// Load level with incremented level prefix (for view IDs)
if (Network.isServer)
{
networkView.RPC( “LoadLevel”, RPCMode.AllBuffered, “globo_server”,lastLevelPrefix + 1);
}
else
{
networkView.RPC( “LoadLevel”, RPCMode.AllBuffered, “globo”,lastLevelPrefix + 1);
}
}
}
}
And the problem is that when I run my editor “server” version and my webclient version and the first initiates a server and the second joins to the server as a client it returns me and error which says:
Level ‘globo’ (-1) couldn’t be loaded because it has not been added to the build settings.
To add a level to the build settings use the menu File->Build Settings…
UnityEngine.Application:LoadLevel(String)
$:MoveNext() (at Assets/Scripts/NetworkLevelLoad.js:40)
I tried to differenciate whether the player is a server or not and still is looking for the level I eliminated/changed for the building of the client version of my game when I click on the button “NameOfMyGame” (which calls to the scene/level of the single player version of my game)…
I think that what’s happening is that I can’t differenciate a version for the client and a version for the server and always are trying to execute the same levels and version of the game.
I want that when I execute my server version appears to me a level/scene with some buttons to control the game of the client version, which consists of a complete different scene/level where the action of the game takes place. The idea is that the server should can control some parameters and aspects of the client’s version game in real time via some buttons. But the first step is to connect them with different scenes/levels.
Anyway, I’ve added a script which trough a button in the scene of the server tries to disable a massive instantiation which occurs during all the game of the client game and it doesn’t work. the way I try to do this is adding a condition via an “if” sentence before the instantiation which depends on a global variable I created for this purpose.
How can I solve my both problems?.
Thank you in adavance.