Created a very simple true-sync scene from tutorial - still doesn't work

Options
I created a very simple scene. It has a set of 4 controllers as UI elements.

When a button gets pushed on one computer, the controller matching that player should light up. Simple!

The code is incredibly light. I am even using Prefabs to create the player objects. However, one client says that there are 2 players connected and the other says there is only one player connected.

I have no idea why. I get this error:

KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[System.Byte,TrueSync.TSPlayer].get_Item (Byte key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
TrueSync.AbstractLockstep.OnEventDataReceived (Byte eventCode, System.Object content)
TrueSync.PhotonTrueSyncCommunicator+c__AnonStorey0.<>m__0 (Byte eventCode, System.Object content, Int32 senderId) (at Assets/Standard Assets/TrueSync/Unity/PhotonTrueSyncCommunicator.cs:43)
NetworkingPeer.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Standard Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2515)
ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (System.Byte[] inBuff)
ExitGames.Client.Photon.EnetPeer.DispatchIncomingCommands ()
ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands ()
PhotonHandler.Update () (at Assets/Standard Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:157)


Here's *all* of the code used:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ControllerConnection : Photon.PunBehaviour {

// Use this for initialization
void Start () {
PhotonNetwork.automaticallySyncScene = true;
PhotonNetwork.ConnectUsingSettings ("v1.0");
var player = PhotonNetwork.player;
player.NickName = string.Format("Controller {0}", player.ID);
}
public override void OnJoinedLobby()
{
PhotonNetwork.JoinOrCreateRoom ("room1234", null, null);
}
public override void OnJoinedRoom()
{
}

void OnGUI() {
GUI.Label (new Rect(10, 10, 100, 30), "players: " + PhotonNetwork.playerList.Length);

if (PhotonNetwork.isMasterClient && GUI.Button (new Rect (10, 40, 100, 30), "start")) {
PhotonNetwork.LoadLevel ("NetworkedInputTest/ControlUI");
}
}
}

public class LightInputModule : BaseTrueSyncBehaviour {

LightActionSet actionSet = null;

private ServerPlayerNumber _playerNumber = ServerPlayerNumber.None;
[Show]
public ServerPlayerNumber PlayerNumber
{
get { return _playerNumber; }
set {
if ( value != _playerNumber )
{
_playerNumber = value;
RepickFeeback();
}
}
}

[Show]
ControllerFeedback feedback = null;

void Start()
{
actionSet = new LightActionSet();

_playerNumber = (ServerPlayerNumber) this.owner.Id;

RepickFeeback();
}

void RepickFeeback()
{
if ( PlayerNumber == ServerPlayerNumber.Player1 )
feedback = GameObject.Find("Player 1 Controller").GetComponent();
else if ( PlayerNumber == ServerPlayerNumber.Player2 )
feedback = GameObject.Find("Player 2 Controller").GetComponent();
else if ( PlayerNumber == ServerPlayerNumber.Player3 )
feedback = GameObject.Find("Player 3 Controller").GetComponent();
else if ( PlayerNumber == ServerPlayerNumber.Player4 )
feedback = GameObject.Find("Player 4 Controller").GetComponent();
}

public override void OnSyncedInput()
{
TrueSyncInput.SetTSVector2(0, actionSet.LeftStickAxis.Vector);
TrueSyncInput.SetTSVector2(1, actionSet.RightStickAxis.Vector);

TrueSyncInput.SetBool(0, actionSet.Back.IsPressed );
TrueSyncInput.SetBool(1, actionSet.Start.IsPressed );
TrueSyncInput.SetBool(2, actionSet.XBox.IsPressed );

TrueSyncInput.SetBool(3, actionSet.ButtonA.IsPressed );
TrueSyncInput.SetBool(4, actionSet.ButtonB.IsPressed );
TrueSyncInput.SetBool(5, actionSet.ButtonX.IsPressed );
TrueSyncInput.SetBool(6, actionSet.ButtonY.IsPressed );

TrueSyncInput.SetBool(7, actionSet.LeftBumper.IsPressed );
TrueSyncInput.SetBool(8, actionSet.RightBumper.IsPressed );
TrueSyncInput.SetBool(9, actionSet.LeftTrigger.IsPressed );
TrueSyncInput.SetBool(10, actionSet.RightTrigger.IsPressed );

TrueSyncInput.SetBool(11, actionSet.DPad_Up.IsPressed );
TrueSyncInput.SetBool(12, actionSet.DPad_Left.IsPressed );
TrueSyncInput.SetBool(13, actionSet.DPad_Down.IsPressed );
TrueSyncInput.SetBool(14, actionSet.DPad_Right.IsPressed );

}

public override void OnSyncedUpdate ()
{
FP inputHorizontal = TrueSyncInput.GetFP (0);
FP inputVertical = TrueSyncInput.GetFP (1);

if ( feedback != null )
{
feedback.moveStickInput = TrueSyncInput.GetTSVector2(0).ToVector();
feedback.cameraStickInput = TrueSyncInput.GetTSVector2(1).ToVector();

feedback.Select = TrueSyncInput.GetBool(0);
feedback.Start = TrueSyncInput.GetBool(1);
feedback.Xbox = TrueSyncInput.GetBool(2);

feedback.ButtonA = TrueSyncInput.GetBool(3);
feedback.ButtonB = TrueSyncInput.GetBool(4);
feedback.ButtonX = TrueSyncInput.GetBool(5);
feedback.ButtonY = TrueSyncInput.GetBool(6);

feedback.LeftBumper = TrueSyncInput.GetBool(7);
feedback.RightBumper = TrueSyncInput.GetBool(8);
feedback.LeftTrigger = TrueSyncInput.GetBool(9);
feedback.RightTrigger = TrueSyncInput.GetBool(10);

feedback.DPadUp = TrueSyncInput.GetBool(11);
feedback.DPadLeft = TrueSyncInput.GetBool(12);
feedback.DPadDown = TrueSyncInput.GetBool(13);
feedback.DPadRight = TrueSyncInput.GetBool(14);
}
//Debug.LogFormat("OnSyncedUpdate ({0}, {1})", inputHorizontal, inputVertical);
}
}


It works just fine for the controller detected - the buttons light up appropriately.... but one client says 2 people are connected and the other says 1 person is connected.

I have made this as simple as possible. What's going on?

Comments

  • Xelnath
    Options
    Furthermore, you're releasing this package for free... why is it closed source. -_-

    If could debug where the problem is, I could probably resolve it.
  • JeffersonHenrique
    Options
    Hi @Xelnath,
    It is open source because we are improving TrueSync first, we are getting a lot of feedback from the community to move on to something more sophisticated. About your issue can you send me a pack by PM, I can look better. Thanks!
  • Xelnath
    Options
    Sure.

    Did you get my question or the answer negated btw?
  • JeffersonHenrique
    Options
    Hi @Xelnath, did you mean the question about the closed source? or the first one about your issue?
  • kyubun2
    Options
    I have the same issue now.
    What's this error?
  • JeffersonHenrique
    Options
    Hey @kyubun2, did you the same code? how did you implement TS Behaviour?
  • kyubun2
    Options
    Sorry, I have another code.
    I upload my code on github.
    https://github.com/kyubuns/OnlineCoinPusher

    Steps to Reproduce
    1. git clone
    2. Download PhotonTrueSync from AssetStore.
    3. Build osx client
    4. Crash when connect guest to host client.

    Unity 5.6.0p4 on macOS Sierra(10.12.5)
  • JeffersonHenrique
    Options
    Hum thanks, can you send the logs?
  • kyubun2
    Options
    Error log on Host client.
    (Client has no error, but no synced)
    KeyNotFoundException: The given key was not present in the dictionary.
    System.Collections.Generic.Dictionary`2[System.Byte,TrueSync.TSPlayer].get_Item (Byte key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
    TrueSync.AbstractLockstep.OnEventDataReceived (Byte eventCode, System.Object content)
    TrueSync.PhotonTrueSyncCommunicator+<AddEventListener>c__AnonStorey0.<>m__0 (Byte eventCode, System.Object content, Int32 senderId) (at Assets/TrueSync/Unity/PhotonTrueSyncCommunicator.cs:43)
    NetworkingPeer.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2515)
    ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (System.Byte[] inBuff)
    ExitGames.Client.Photon.TPeer.DispatchIncomingCommands ()
    ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands ()
    PhotonHandler.Update () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:157)
  • kyubun2
    Options
    Error log on Host.
    (Client has no error, but not synced.)
    KeyNotFoundException: The given key was not present in the dictionary.
    System.Collections.Generic.Dictionary`2[System.Byte,TrueSync.TSPlayer].get_Item (Byte key) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:150)
    TrueSync.AbstractLockstep.OnEventDataReceived (Byte eventCode, System.Object content)
    TrueSync.PhotonTrueSyncCommunicator+<AddEventListener>c__AnonStorey0.<>m__0 (Byte eventCode, System.Object content, Int32 senderId) (at Assets/TrueSync/Unity/PhotonTrueSyncCommunicator.cs:43)
    NetworkingPeer.OnEvent (ExitGames.Client.Photon.EventData photonEvent) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:2515)
    ExitGames.Client.Photon.PeerBase.DeserializeMessageAndCallback (System.Byte[] inBuff)
    ExitGames.Client.Photon.TPeer.DispatchIncomingCommands ()
    ExitGames.Client.Photon.PhotonPeer.DispatchIncomingCommands ()
    PhotonHandler.Update () (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:157)
  • JeffersonHenrique
    Options
    Hi @kyubun2, I suggest you to took at our demos and try to develop your game over some of them, because you are using some PUN's callback that doesn't work with TrueSync. With TS you have a specific way to start the scene.