Photon TrueSync is giving un-debuggable errors

I get this spammed to my window when I create a TrueSync manager then add players to it as they login:
NullReferenceException: Object reference not set to an instance of an object TrueSync.TrueSyncManagedBehaviour.OnSyncedStart () TrueSync.TrueSyncManager.OnGameStarted () (at Assets/Standard Assets/TrueSync/Unity/TrueSyncManager.cs:838) TrueSync.AbstractLockstep.Run () TrueSync.AbstractLockstep.RunSimulation (Boolean firstRun) TrueSync.AbstractLockstep.CheckGameStart () TrueSync.AbstractLockstep.Update () TrueSync.TrueSyncManager.FixedUpdate () (at Assets/Standard Assets/TrueSync/Unity/TrueSyncManager.cs:697)

Comments

  • Hi @Xelnath, are you adding players in a "late join" way? Can you give more details how are you creating TSManager? Thanks.
  • XelnathXelnath
    edited February 2017
    I'm trying. Here's the code:

    public TrueSync.TrueSyncManager TrueSyncManager = null; public override void OnPhotonPlayerConnected( PhotonPlayer other ) { DebugLogFormat( "OnPhotonPlayerConnected() " + other.NickName ); // not seen if you're the player connecting DetectPhotonPlayers(); } public void SetupTrueSync() { if ( TrueSyncManager == null ) { GameObject go = new GameObject("TrueSyncManager"); DontDestroyOnLoad(go); TrueSyncManager = go.AddComponent(); } } public override void OnJoinedRoom () { DetectPhotonPlayers(); } public void DetectPhotonPlayers() { DebugLogFormat("Detecting players: {0}", PhotonNetwork.playerList.Length ); SetupTrueSync(); if ( PhotonNetwork.isMasterClient == false ) { DebugLogFormat("You are not the master. You cannot pick out new ServerIDs. (PhotonPlayer {0})", PhotonNetwork.player.ID ); return; } for ( int i = 0; i < PhotonNetwork.playerList.Length; i++ ) { PhotonPlayer player = PhotonNetwork.playerList[i]; if ( player.TagObject == null ) { var network = FindObjectOfType(); network.SpawnNewPlayerObject(player); } } } .... SpawnNewPlayerObject() { .... create some objects. // Register again TrueSyncManager.AddPlayer(player, go); } public void AddPlayer(PhotonPlayer player, GameObject playerObject) { lockstep.AddPlayer((byte)player.ID, player.NickName, player.IsLocal); TSPlayer p = lockstep.Players[(byte)player.ID]; List behaviorsInstatiated = new List(); TrueSyncBehaviour[] behaviours = playerObject.GetComponentsInChildren(); foreach (TrueSyncBehaviour behaviour in behaviours) { behaviour.owner = p.playerInfo; behaviour.localOwner = lockstep.LocalPlayer.playerInfo; behaviour.numberOfPlayers = lockstep.Players.Count; TrueSyncManagedBehaviour tsmb = NewManagedBehavior(behaviour); tsmb.owner = behaviour.owner; tsmb.localOwner = behaviour.localOwner; behaviorsInstatiated.Add(tsmb); } behaviorsByPlayer.Add( p.ID, behaviorsInstatiated); }
  • In a nutshell, I attempted to fully replicate all of the same setup steps as occurs for a player detected at scene load.
  • I understood, unfortunately our lockstep core doesn't support that. Another thing that is important to mention is "OnPhotonPlayerConnected" callback deterministic which means it can be triggered at different frames in two different clients.
  • I see.

    It seems like the player-connected message could be capture by all clients, then when they agree a player exists, simultaneously add the new player in the same frame.

    This type of basic gate-keeping seems very feasible, yes?
  • Sure @Xelnath, it is an option, but one of the problems is that the new player has to simulate all the frame until the frame he was accepted, it can take a lot of time in a basic implemetation and other players have to wait for this (lag).
Sign In or Register to comment.