Author Topic: RFC RCC Parms not getting passed  (Read 3909 times)

phil.atha

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 18
    • View Profile
RFC RCC Parms not getting passed
« on: July 17, 2017, 01:10:45 AM »
Are there any known issues with parameters not getting pass or passed unreliably?

I'm passing a simple int to a function using tno.Send and it doesn't make it over to the function. Sometimes if I call SendQuickly it will work but its unreliable. I could be in an edge-case situation but I can't be sure. In doing my debug tracing I know the value is making it to my GeneratePlanet function just fine but from there it never makes it to the target  class and I can't figure out why. Anything glaringly obvious I'm doing wrong here?

Speaking of debugging, sometimes when attaching VS to Unity I sometimes experience issues with all the TNet functions firing. Does that happen to anyone else?

Code sample is as follows:
  1. class PFactory
  2. {
  3.         IEnumerator GenerateScene()
  4.         {
  5.             GUIManager.instance.SetState(GameState.Loader);
  6.             GameSettings _settings = ReadSettings();
  7.  
  8.             yield return new WaitForSeconds(2);
  9.  
  10.             //Some super secret code here ;p
  11.  
  12.             int perlinSeed = Random.Range(0, 90000);
  13.             TNet.TNManager.Instantiate(GameNetwork.instance.channel.id, "GeneratePlanet", path, true, perlinSeed);
  14.  
  15.             yield return new WaitForSeconds(2); //At least 1 seconds of loading screen
  16.             GameNetwork.instance.isLevelBuilt = true;
  17.         }
  18.  
  19.         [TNet.RCC]
  20.         static GameObject GeneratePlanet(GameObject prefab, int seedVal)
  21.         {
  22.             GameObject _planet = Instantiate(prefab) as GameObject;
  23.  
  24.             PBuilder pbr = _planet.GetComponent<PBuilder>();
  25.             //tns.tno.Send("Generate", TNet.Target.All, seedVal); //Never works
  26.                tns.tno.SendQuickly("Generate", TNet.Target.All, seedVal); //Barely works
  27.            
  28.             //Generate Vegetation
  29.            
  30.             //Cleanup
  31.  
  32.             return _planet;
  33.         }
  34. }
  35.  
  36. class PBuilder
  37. {
  38.         [TNet.RFC]
  39.         public void Generate(int seed)
  40.         {
  41.             perlinSeed = seed; //This value is always 0
  42.             //Magic Happens
  43.         }
  44. }
  45.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: RFC RCC Parms not getting passed
« Reply #1 on: July 17, 2017, 06:18:59 AM »
Don't send anything inside an RCC call. The object isn't actually there yet. It doesn't get initialized fully until after the function ends and TNet can assign a TNObject ID to it. The function call itself is unnecessary anyway, the RCC gets called on all clients -- why send a message to everyone when they already received this function call and can just call Generate inside it?

phil.atha

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: RFC RCC Parms not getting passed
« Reply #2 on: July 18, 2017, 10:24:58 AM »
Thanks Aren, I'll work towards that. In order to reduce overhead I'm having the clients each generate their own planets but I'm doing it with a common seed parameter so the result is exactly the same across all clients. I need to know when the Instantiate function completes so that it's ready/safe to send the parameter to the clients and kick off the process. Could I hook a delegate up to the RCC call?

cmifwdll

  • Global Moderator
  • Sr. Member
  • *****
  • Thank You
  • -Given: 0
  • -Receive: 149
  • Posts: 285
  • TNet Alchemist
    • View Profile
Re: RFC RCC Parms not getting passed
« Reply #3 on: July 18, 2017, 10:42:10 AM »
TNManager.Instantiate is a networked creation call, so your GeneratePlanet function is called on every client with the same seedVal argument at roughly the same time.
From within your GeneratePlanet function, you can call Generate directly - as you would any normal function. Strip away its RFC attribute too, don't need it.
  1. class PFactory
  2. {
  3.         IEnumerator GenerateScene()
  4.         {
  5.                 GUIManager.instance.SetState(GameState.Loader);
  6.                 GameSettings _settings = ReadSettings();
  7.  
  8.                 yield return new WaitForSeconds(2);
  9.  
  10.                 //Some super secret code here ;p
  11.  
  12.                 int perlinSeed = Random.Range(0, 90000);
  13.                 TNet.TNManager.Instantiate(GameNetwork.instance.channel.id, "GeneratePlanet", path, true, perlinSeed);
  14.  
  15.                 yield return new WaitForSeconds(2); //At least 1 seconds of loading screen
  16.                 GameNetwork.instance.isLevelBuilt = true;
  17.         }
  18.  
  19.         [TNet.RCC]
  20.         static GameObject GeneratePlanet(GameObject prefab, int seedVal)
  21.         {
  22.                 // this is executed on every client automagically
  23.                 GameObject _planet = Instantiate(prefab) as GameObject;
  24.  
  25.                 PBuilder pbr = _planet.GetComponent<PBuilder>();
  26.                 // direct function call since the clients themselves are executing this
  27.                 pbr.Generate(seedVal);
  28.  
  29.                 //Generate Vegetation
  30.  
  31.                 //Cleanup
  32.  
  33.                 return _planet;
  34.         }
  35. }
  36.  
  37. class PBuilder
  38. {
  39.         public void Generate(int seed)
  40.         {
  41.                 perlinSeed = seed; //This value is always 0
  42.                 //Magic Happens
  43.         }
  44. }
  45.  

phil.atha

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 18
    • View Profile
Re: RFC RCC Parms not getting passed
« Reply #4 on: July 18, 2017, 09:53:41 PM »
Thanks so much guys, removing the RFC seemed to be the specific thing that fixed it.