I have a question to which I am not able to find any answer. So I’m making a pretty bulky game and I need to have a ton of scenes. I’m not very well versed in Unity, so maybe it’s the user who’s at fault
I have a TCP connection between a server and multiple clients using NetworkTransport API.
So the problem is, when I do this on the client, I lose the connection:
Client:
StartCoroutine(LoadNextSceneAsync("Level 2")); // Simply loads async scene through SceneManager
And whenever the scene is loaded, the client simply disconnects, even though the NetworkManager gameobject, that has the client script, is set to DontDestroyOnLoad();
Another problem is that if the gameobject, that is not destroyed, transfers to the next scene, how do I reference it in the scripts within that new scene, because these objects don’t exist in that scene, and I can’t compile the code. For example:
// Scene 1:
// Network Game Objects have DontDestroyOnLoad() casted on them.
SceneManager.LoadSceneAsync("Level 2");
// Scene 2:
/* Has other Game Objects and scripts that call for variables in network objects from Scene 1 that are hopefully now transferred*/
PlayerName = NetworkManager.GetClientName(); // NetworkManager object doesn't exist in scene 2 two until transferred from Scene 1.
Question: How to properly manage scenes within the client, and not lose connection to the server, while at the same time transferring the NetworkManager Game Object through all scenes?