- Home /
Do I need Smartfox server for a client and server in different "rooms" or scenes or scenearios?
Hello my friends.
Do you know If I need SmartFox server for doing this instead the built in capabilities of Unity3D in networking?
My idea is: to create a game in which one player starts to play in an scenario, in a forest, and there's a "super-user" in other PC who controls certain parameters like the difficulty level and others. It's strange that something so simple can't be managed byself in Unity: only two players but in different scenarios. I've created my two applications (a web client) and a server version but the last one instead of going after clicking in a button of my menu scene (common for both versions) to the forest (just like in the client version) goes to a scene/scenario/level where appears a serie of buttons for controlling some parameters like the level of difficulty or the appearing/spawning of enemies...
I receive the message when I click a button in my server version:
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 build two different games with different scenarios at each level and the debugger tell me this error message: I can't modify any global variable due to the change of the name of the scene at level2 (when I build one of both versions of my game).
I think I'm gonna start to study SmartFox... :-( As one friend has recommended to me...
But before that I wanted to know your opinion.
Please, remember I'm ompletely new at networking with Unity3D.
Thanks in advance.
I've tried to create for both versions the same project and loaded one or another level depending on whether you are the client or the server. And after checking that client can connect to the server and each one within his own scene I'm trying to modify a script (for example) from the server's scene to the client scene via this code:
function OnGUI () {
if (GUI.Button(new Rect(500,500,250,20),"turn_off_the_script"))
print("click_on_the_button");
networkView.RPC ("off", RPC$$anonymous$$ode.All);
print("llamo a la función");
}
@RPC
function off ()
{
var go = GameObject.Find("Generator");
print("object_found");
go.GetComponent("script_to_turn_off").enabled=false;
print("script_turned_off");
}
But unfortunatelly I receive the next error message:
NullReferenceException UnityEngine.GameObject.GetComponent (System.String type) (at C:/BuildAgent/work/6bc5f79e0a4296d6/Runtime/ExportGenerated/Editor/BaseClass.cs:185) Botones_menu.deshabilita_lluvia () (at Assets/Scripts/Botones_menu.js:23) UnityEngine.NetworkView:RPC(String, RPC$$anonymous$$ode, Object[]) Botones_menu:OnGUI() (at Assets/Scripts/Botones_menu.js:15)
It seems that It can't find the component / script. Is my code correct?. In this case, maybe is it possible because of I'm using different scenes for each game version (one for the server which is the code I've posted before in this post) through the code, inside the code I select one or other scene depending on whether I'm server or client.
Thank you in advance.