Author Topic: lobbyPlayer(just UI) and gamePlayer  (Read 1237 times)

Elmo loves cookies

  • Jr. Member
  • **
  • Thank You
  • -Given: 60
  • -Receive: 1
  • Posts: 62
    • View Profile
lobbyPlayer(just UI) and gamePlayer
« on: February 01, 2018, 01:30:10 AM »
I create channel by this: TNManager.JoinChannel(Random.Range(10000, 99999), "", false, 8, "", false);
other connect here through channelList;

afterConnect to channel everybody create his lobbyPlayer(just UI with TNobject for sync RFC):

  1. TNManager.Instantiate(mChannelID, "CreateLobbyPlayer", "LobbyPlayer", false, TNManager.player.id, TNManager.player.name);
  2.  
  3. [RCC]
  4.     static GameObject CreateLobbyPlayer(GameObject prefab, int id, string pName)
  5.     {
  6.         GameObject go = prefab.Instantiate();
  7.         LobbyPlayer obj = go.GetComponent<LobbyPlayer>();
  8.         obj.Set(pName);
  9.         if (id == TNManager.player.id)
  10.         {
  11.             localLobbyPlayer = obj;
  12.         }
  13.         return go;
  14.     }
  15.  

and then playerHost start round for everyOne, by send RFC from "localLobbyPlayer.TNobject"

  1. TNManager.LoadLevel("sceneOne");

on loaded new scene everyody spawn his own gamePlayers:

  1. TNManager.Instantiate("CreatePlayer", "playerPrefabObject", false, spawn.position, spawn.rotation, TNManager.player.id);
  2.  
  3. [RCC]
  4.     static GameObject CreatePlayer(GameObject go, Vector3 pos, Quaternion rot, int id)
  5.     {
  6.         go = Instantiate(go, pos, rot) as GameObject;
  7.         if (TNManager.player.id == id)
  8.         {
  9.             localPlayer = go.GetComponent<PlayerController>();
  10.         }
  11.         AllPlayers.Add(go.GetComponent<TNObject>().ownerID, go.GetComponent<PlayerController>());
  12.         return go;
  13.     }
  14.  

well, after round I goOut in new scene "LobbyScene" by this:
  1. TNManager.LoadLevel("LobbyScene");
  2.  
all network objects have destoyed - we dont have lobbyPlayer(because "LoadLevel") go again create it for everybody,

thats correctly? my way is wrong for making lobby system?
« Last Edit: February 01, 2018, 01:36:38 AM by Elmo »