Cannot get the game scene to load properly

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) {

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)

I'm not sure what other information to include to make this more clear, just let me know what I need to provide

Best Answer


Sign In or Register to comment.