NullReferenceException on StartGame
Hello!
I wanted to start using Photon Fusion today and walked through the Getting Started section. I simply got the latest version (Photon-Fusion-0.13.0-RC-Nightly-406) on Unity version 2021.1.6f1 and also installed mono.cecil to a fresh 3d hdrp project. I created my AppId and used the wizard to store it. I simply almost copy and pasted the "Fusion 102 - Setting Up A Scene - Launching Fusion"-Code. But after "_launcher.StartGame" is called, NullReferenceException was thrown and the NetworkRunner shuts down.
Exceptions:
Even if i use the Feature "Fusion -> GameObject -> Setup Basic Fusion Scene" without my own Scripts/GameObjects, the same errors occur.
All my scenes are added to the Build-Settings aswell.
My code, but as i said, the same thing:
using System; using System.Collections; using System.Collections.Generic; using Fusion; using Fusion.Sockets; using UnityEngine; using UnityEngine.SceneManagement; public class NetworkBaseLogic : MonoBehaviour, INetworkRunnerCallbacks { public NetworkRunner Runner { get; private set; } public async void StartGame(GameMode mode) { Runner = gameObject.AddComponent<NetworkRunner>(); Runner.ProvideInput = true; var sceneManager = gameObject.AddComponent<NetworkSceneManagerDefault>(); var startGameResult = await Runner.StartGame(new StartGameArgs() { GameMode = mode, SessionName = "Room Test 1", Scene = SceneManager.GetActiveScene().buildIndex, SceneObjectProvider = sceneManager, }); Debug.Log("DebugResult: "+startGameResult); } private void OnGUI() { if (Runner == null) { if (GUI.Button(new Rect(0, 0, 200, 40), "Host")) { StartGame(GameMode.Host); } if (GUI.Button(new Rect(0, 40, 200, 40), "Join")) { StartGame(GameMode.Client); } } } public void OnPlayerJoined(NetworkRunner runner, PlayerRef player) { } public void OnPlayerLeft(NetworkRunner runner, PlayerRef player) { } public void OnInput(NetworkRunner runner, NetworkInput input) { } public void OnInputMissing(NetworkRunner runner, PlayerRef player, NetworkInput input) { } public void OnShutdown(NetworkRunner runner, ShutdownReason shutdownReason) { } public void OnConnectedToServer(NetworkRunner runner) { } public void OnDisconnectedFromServer(NetworkRunner runner) { } public void OnConnectRequest(NetworkRunner runner, NetworkRunnerCallbackArgs.ConnectRequest request, byte[] token) { } public void OnConnectFailed(NetworkRunner runner, NetAddress remoteAddress, NetConnectFailedReason reason) { } public void OnUserSimulationMessage(NetworkRunner runner, SimulationMessagePtr message) { } public void OnSessionListUpdated(NetworkRunner runner, List<SessionInfo> sessionList) { } public void OnCustomAuthenticationResponse(NetworkRunner runner, Dictionary<string, object> data) { } public void OnReliableDataReceived(NetworkRunner runner, PlayerRef player, ArraySegment<byte> data) { } public void OnSceneLoadDone(NetworkRunner runner) { } public void OnSceneLoadStart(NetworkRunner runner) { } }
I hope someone can help me with this issue.
Best regards
Best Answer
-
Thanks for answering. I asked this some days ago, so in the mean time it "resvolved" itself (Posts are taking long time for being approved..)
For anybody wondering: It was an actual bug in the NetworkRunner, there was an incorrect null-check at the AddBehavior method. But Version 0.13.0 Build 408 (and above i hope) fixes that problem. Build 406 only got this issue.
0
Answers
-
It would be good to see the complete callstack of the error.
I would suggest to update the Fusion SDK to latest. While I don't see if one of the fixes helps in this case, there are several.
Last but not least, we will double check our Getting Started doc with the latest version.
0 -
Thanks for answering. I asked this some days ago, so in the mean time it "resvolved" itself (Posts are taking long time for being approved..)
For anybody wondering: It was an actual bug in the NetworkRunner, there was an incorrect null-check at the AddBehavior method. But Version 0.13.0 Build 408 (and above i hope) fixes that problem. Build 406 only got this issue.
0 -
Sometimes our devs are too busy and forget to check the forum.
Thanks for your update! Glad you checked out the updated SDK.
0