Search Unity

error on client: Did not find target for sync message for 2

Discussion in 'Multiplayer' started by xeonheart, Sep 5, 2021.

  1. xeonheart

    xeonheart

    Joined:
    Jul 24, 2018
    Posts:
    219
    Hello,

    so I am working on host and client join game, and yes i do have 2 threads open, but both are separate, today I received this error message, which came out of nowhere as this is the first time running into this, and was working yesterday but now the Synvar is not working and is showing this message:

    Did not find target for sync message for 2 . Note: this can be completely normal because UDP messages may arrive out of order, so this message might have arrived after a Destroy message.

    also I am using DapperDino example but just added a new variable to display ONLY the number of players in the lobby, so not all 4 player panels will be displayed, but only how many MAX they want to be in the game.

    in short, its coming from this script, and variable, its on script called NetworkRoomPlayerLobby:

    Code (CSharp):
    1.         [SyncVar]
    2.         public int maxPlayers = 1;
    3.  
    4. private void GetMaxPlayers(int num)
    5.         {
    6.             maxPlayers = NetworkVariables.maxPlayers;//GameConfig.playerCount;
    7.         }
    8.  
    9.         public override void OnStartClient()
    10.         {
    11.             Room.RoomPlayers.Add(this);
    12.  
    13.             GetMaxPlayers(NetworkVariables.maxPlayers);
    14.             Debug.Log(maxPlayers.ToString());
    15.  
    16.             UpdateDisplay();
    17.  
    18.             if (!isLeader)
    19.             {
    20.                 startGameButton.gameObject.SetActive(false);
    21.             }
    22.         }
    23.  
    24.  
    the NetworkVariables is a custom Script that is a static int:

    Code (CSharp):
    1.  public class NetworkVariables : NetworkBehaviour
    2.     {
    3.         public static int maxPlayers = 1;
    4.     }
    and gets assigned how many players when a player or the host presses the 1, 2, 3, or 4 button for how many players on script called GameConfig:

    Code (CSharp):
    1.     public class GameConfig : NetworkBehaviour
    2.     {
    3.         public NetworkVariables networkVariables;
    4.  
    5.         public void GetPlayerCount(int num)
    6.         {
    7.             NetworkVariables.maxPlayers = num;
    8.         }
    9. }
    so not sure if I need to put the "GetMaxPlayers(NetworkVariables.maxPlayers);" on script NetworkRoomPlayerLobby in a different method? or something else is going on? the Server/Host works and shows the number of correct panels.... BUT the client or player that joins the room, is blank, meaning the error message:

    Did not find target for sync message for 2 . Note: this can be completely normal because UDP messages may arrive out of order, so this message might have arrived after a Destroy message.

    comes up :(