Author Topic: RFCs not being received.  (Read 2174 times)

vidjogamer

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 48
    • View Profile
RFCs not being received.
« on: January 16, 2014, 09:42:36 AM »
I cant quite figure it out. I think it has something to do with the TNObjects. I have several GameObjects with TNObjects in my scene. Now, I have this script on my objects:

  1. using UnityEngine;
  2. using System.Collections;
  3. using TNet;
  4.  
  5. public class TNetSyncEnabled : TNBehaviour {
  6.  
  7.         public void OnEnable () {
  8.         if(TNManager.isConnected && TNManager.isHosting)
  9.         {
  10.             KGFDebug.LogDebug("OnEnable() Called", "TNetSyncEnabled");
  11.             tno.Send("Sync", Target.Others, true);
  12.         }
  13.         }
  14.        
  15.         public void OnDisable () {
  16.         if(TNManager.isConnected && TNManager.isHosting)
  17.         {
  18.             KGFDebug.LogDebug("OnDisable() Called", "TNetSyncEnabled");
  19.             tno.Send("Sync", Target.Others, false);
  20.         }
  21.         }
  22.  
  23.     [RFC]
  24.     public void Sync(bool enabled)
  25.     {
  26.         KGFDebug.LogDebug("Sync() RFC Called", "TNetSyncEnabled");
  27.         this.gameObject.SetActive(enabled);
  28.     }
  29. }
  30.  

All the objects are in the scene from the start. None are created dynamically. Now the problem is that some of them work and some of them dont and I just cant figure out why. I thought maybe script order had something to do with it, so I moved TNManager and TNObject before any of personal scripts. I think that may have fixed some of them. One object only works if its enabled when I start my game. If I have it disabled when I start it doesnt work. Other objects that start disabled DO work though. And one object that starts enabled DOESNT work. I'm pretty sure they all have unique IDs.  The only thing I can think thats different about one of them is that it might have children under it with their own TNObjects. I'm not even sure if that would affect it. Thats basically the entire scenario. Thats the script im using to test. So I'm guessing it has something to do with initialization. Any ideas what would prevent RFCs from working given the info I have shared?
« Last Edit: January 16, 2014, 03:25:51 PM by vidjogamer »

vidjogamer

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 48
    • View Profile
Re: RFCs not being received.
« Reply #1 on: January 16, 2014, 10:22:03 AM »
Actually, one of the objects I was testing was the entire StarLink menu scene added to a parent root Object that just had the TNObject and the TNetSyncEnabled script. It just occurred to me that there could be something going on in one of the child objects that interferes with it maybe? I dont need this object in particular to work, I just set it up this way for testing, but I do want to understand the system better and get to the bottom of the issue as to avoid it in the future.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: RFCs not being received.
« Reply #2 on: January 17, 2014, 12:48:27 AM »
If you disable the object, it won't be capable of receiving RFC calls. You should have a "target" variable, where your script will disable or enable a target game object/script. Never itself, and never its own game object.

vidjogamer

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 48
    • View Profile
Re: RFCs not being received.
« Reply #3 on: January 17, 2014, 02:25:54 AM »
Thank you Aren.