Cannot get the game scene to load properly
Options
ambid17
✭
in Photon Bolt
I am using the latest version of Bolt on Unity 2018.2, and I cannot figure out how to properly deal with connections.
I am using the sample scene PhotonLobby in samples/PhotonCloud/Scenes. I changed the game scene to be my scene that has my main level.
I created my own ServerCallbacks, that looks something like this:
[BoltGlobalBehaviour(BoltNetworkModes.Server, "Main")]
public class FNSServerCallbacks : Bolt.GlobalEventListener {
...
public override void SceneLoadRemoteDone(BoltConnection connection) {
connection.GetPlayer().InstantiateEntity();
}
...
}
I also copied the ExtensionMethods.cs script and made my own since I changed the name of the Player class, it looks the same:
public static class ExtensionMethods {
public static PlayerObject GetPlayer(this BoltConnection connection) {
if (connection == null) {
return PlayerObject.serverPlayer;
}
return (PlayerObject)connection.UserData;
}
}
To get the error to pop up I build the project with both scenes, get the players into the lobby, hit join, and then when the Main scene loads, it gives me the following error (connection.UserData is null):
InvalidCastException: Cannot cast from source type to destination type.
ExtensionMethods.GetPlayer (.BoltConnection connection) (at Assets/Scripts/Networking/ExtensionMethods.cs:11)
FNSServerCallbacks.SceneLoadRemoteDone (.BoltConnection connection) (at Assets/Scripts/Networking/FNSServerCallbacks.cs:43)
BoltInternal.GlobalEventListenerBase.SceneLoadRemoteDoneInvoke (.BoltConnection connection)
UnityEngine.Debug:LogException(Exception)
BoltLog:Exception(Exception)
BoltInternal.GlobalEventListenerBase:SceneLoadRemoteDoneInvoke(BoltConnection)
BoltCore:InvokeRemoteSceneCallbacks()
BoltCore:Poll()
BoltPoll:FixedUpdate()
I'm not sure what other information to include to make this more clear, just let me know what I need to provide
I am using the sample scene PhotonLobby in samples/PhotonCloud/Scenes. I changed the game scene to be my scene that has my main level.
I created my own ServerCallbacks, that looks something like this:
[BoltGlobalBehaviour(BoltNetworkModes.Server, "Main")]
public class FNSServerCallbacks : Bolt.GlobalEventListener {
...
public override void SceneLoadRemoteDone(BoltConnection connection) {
connection.GetPlayer().InstantiateEntity();
}
...
}
I also copied the ExtensionMethods.cs script and made my own since I changed the name of the Player class, it looks the same:
public static class ExtensionMethods {
public static PlayerObject GetPlayer(this BoltConnection connection) {
if (connection == null) {
return PlayerObject.serverPlayer;
}
return (PlayerObject)connection.UserData;
}
}
To get the error to pop up I build the project with both scenes, get the players into the lobby, hit join, and then when the Main scene loads, it gives me the following error (connection.UserData is null):
InvalidCastException: Cannot cast from source type to destination type.
ExtensionMethods.GetPlayer (.BoltConnection connection) (at Assets/Scripts/Networking/ExtensionMethods.cs:11)
FNSServerCallbacks.SceneLoadRemoteDone (.BoltConnection connection) (at Assets/Scripts/Networking/FNSServerCallbacks.cs:43)
BoltInternal.GlobalEventListenerBase.SceneLoadRemoteDoneInvoke (.BoltConnection connection)
UnityEngine.Debug:LogException(Exception)
BoltLog:Exception(Exception)
BoltInternal.GlobalEventListenerBase:SceneLoadRemoteDoneInvoke(BoltConnection)
BoltCore:InvokeRemoteSceneCallbacks()
BoltCore:Poll()
BoltPoll:FixedUpdate()
I'm not sure what other information to include to make this more clear, just let me know what I need to provide
0
Best Answer
-
Both lobby manager and your game are overwriting the connection userdata.5
Answers
-
If you upload a project to Github I can take a look at the details0
-
Here is my project on github: https://gitlab.com/ambid17/InfectAndSeek0
-
Both lobby manager and your game are overwriting the connection userdata.5