- Home /
Question by
kag4380 · Aug 20, 2015 at 10:51 PM ·
networkingunity multiplayer
[UNET] Network object inactive after loading online scene
I'm working on Unity's UNET for networking. My problem is that when network manager takes me to online scene it deactivates all the networked objects. I know that network objects will start executing only after all the scene objects are loaded. But even after all my scene objects have loaded(I don't see any error in console), my network objects are still inactive. What else do I need to check in order to get those scripts running?
Comment
Answer by marcelop · Nov 03, 2015 at 12:17 AM
You have to call NetworkServer.SpawnObjects() on the server once both server and client have fully loaded the scene.
Answer by neopaul78 · Jun 21, 2019 at 03:04 PM
1) Override Awake in script of network object:
void Awake(){ DontDestroyOnLoad(gameObject);}
2) Add prefab of this object to spawn list of NetworkManager
3) OnPlayer script:
void Awake(){ DontDestroyOnLoad (gameObject); }
IEnumerator selfEnab(){ // KORUTINE WAIT LOADIN OF SCENE
yield return new WaitForSeconds (2);
Cmd_Ena(); }
void MyChangeLevel(){ // CALL SPAWN CORUTINE AFTER LOAD SCENE
SceneManager.LoadScene (numlev++, LoadSceneMode.Single);
StartCoroutine ("selfEnab"); }