Author Topic: 'isMine' always false when connected to server  (Read 208 times)

Gabemeister1201

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 9
    • View Profile
'isMine' always false when connected to server
« on: September 07, 2017, 07:01:38 PM »
Hello,

I have been trying to solve this issue now for a couple of hours, and I can't seem to find out what is causing it. My code looks exactly like it does in the "Example Creation" scene, and my TNObjects isMine is always false when I am connected to a server. However, if I am NOT connected to a server, they seem to be working.

Here is what the TNObject looks like in the inspector when I am connected to a server (gyazo link): https://gyazo.com/d74f3d8b16cdc31f4b1f97fcdddf70f8

Here is my code:

*Network Manager*
  1.     private void OnConnect(bool success, string message)
  2.     {
  3.         //Debug.Log("OnJoinedRoom: " + PhotonNetwork.room.Name + " | Players: " + PhotonNetwork.room.PlayerCount + "/" + PhotonNetwork.room.MaxPlayers);
  4.         Debug.Log("OnConnect Message: " + message);
  5.  
  6.         if(success == true)
  7.         {
  8.  
  9.             // Set "inRoom" to true
  10.             inRoom = true;
  11.  
  12.             // Instantiate LobbyController when joined room
  13.             //PhotonNetwork.Instantiate("LobbyController", Vector3.zero, Quaternion.identity, 0);
  14.             TNManager.Instantiate(0, "RCCLobbyController", "LobbyController", false, Vector3.zero, Quaternion.identity);
  15.         }
  16.  
  17.     [RCC]
  18.     static GameObject RCCLobbyController(GameObject prefab, Vector3 pos, Quaternion rot)
  19.     {
  20.         GameObject go = prefab.Instantiate();
  21.  
  22.         // Set the position and rotation based on the passed values
  23.         Transform t = go.transform;
  24.         t.position = pos;
  25.         t.rotation = rot;
  26.  
  27.         return go;
  28.     }
  29.  
  30.  

Here is the script for the lobby controller that is attached to the instantiated object:

  1.     private void Start()
  2.     {
  3.         if(tnObject.isMine == true)
  4.         {
  5.             Debug.Log("isMine");
  6.  
  7.             tnObject.Send("RPCMakePlayerCard", Target.AllSaved, playerName);
  8.  
  9.             networkLobby.readyToggle.onValueChanged.AddListener(SetReady); // Add Toggle onValueChanged() Listener for Ready
  10.             networkLobby.launchButton.onClick.AddListener(PhotonLoadLevel); // Add Button onClick() Listener for launching game
  11.         }
  12.         else
  13.         {
  14.             Debug.Log("Not mine");
  15.         }
  16.     }

As you can see, the "isMine" check is happening in the Start method of the Instantiated Object, so to my understanding, the TNObject has already been initialized and everything should be working. I feel like I am missing something so obvious.

Thanks,
Gabe

cmifwdll

  • Global Moderator
  • Full Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 132
  • Posts: 241
  • TNet Alchemist
    • View Profile
Re: 'isMine' always false when connected to server
« Reply #1 on: September 07, 2017, 11:49:50 PM »
TNObject's belong to channels, not servers. Join a channel in your OnConnect handler, then do everything else in OnJoinChannel.

Gabemeister1201

  • Newbie
  • *
  • Thank You
  • -Given: 4
  • -Receive: 0
  • Posts: 9
    • View Profile
Re: 'isMine' always false when connected to server
« Reply #2 on: September 08, 2017, 08:28:26 PM »
Everything works perfectly now! I should familiarize myself a little more on how TNet is structured.

Thank you very much :)