Author Topic: RFC Not Received  (Read 2461 times)

WolfTechGames

  • Newbie
  • *
  • Thank You
  • -Given: 6
  • -Receive: 4
  • Posts: 35
    • View Profile
RFC Not Received
« on: October 23, 2015, 11:27:25 PM »
When I run my game it doesn't receive the previous RPC's which were sent to allsaved. I have played around with it for hours and am completely clueless. If anyone could help me with this issue I will be extremely grateful!

The following debug statements near the end just return the default values which are "name".
  1.  Debug.Log ("Current Zone Name: " + currentZone.zoneName);
  2.  Debug.Log ("Current Monster Name: " + monsterSpawn.Name);

  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using System.Collections;
  4. using TNet;
  5.  
  6. public class ZoneManager : TNBehaviour
  7. {
  8.         //Singleton
  9.         private static ZoneManager instance = null;
  10.  
  11.         //Other Managers
  12.         private GameManager gm;
  13.  
  14.         //Monster Plate
  15.         [HideInInspector]
  16.         public Monster monsterSpawn;
  17.  
  18.         //List of Monsters
  19.         public Zone[] zones;
  20.         [Space]
  21.         public Zone currentZone = new Zone();
  22.  
  23.         //Singleton Check
  24.         void Awake()
  25.         {
  26.                 // First we check if there are any other instances conflicting
  27.                 if(instance != null && instance != this)
  28.                 {
  29.                         // If that is the case, we destroy other instances
  30.                         Destroy(gameObject);
  31.                 }
  32.                
  33.                 // Here we save our singleton instance
  34.                 instance = this;
  35.                
  36.                 // Furthermore we make sure that we don't destroy between scenes (this is optional)
  37.                 DontDestroyOnLoad(gameObject);
  38.                
  39.                 //Get Zone Manager
  40.                 gm = GameObject.Find("_GameManager").GetComponent<GameManager>();
  41.         }
  42.  
  43.         //Chooses a Zone then updates it to all
  44.         public void pickZone()
  45.         {
  46.                 //Chooses a random Zone
  47.                 int zoneNum = Random.Range (0, zones.Length);
  48.                
  49.                 //Apply the settings to everyone
  50.                 tno.Send ("zoneApply", TNet.Target.AllSaved, zoneNum);
  51.         }
  52.        
  53.         [RFC]
  54.         public void zoneApply(int zoneNumber)
  55.         {
  56.                 //Debug
  57.                 Debug.Log ("Zone(" + zoneNumber + ") Chosen");
  58.                
  59.                 //Apply Zone
  60.                 currentZone = zones [zoneNumber];
  61.                
  62.                 //Change Background
  63.                 GameObject.Find ("Canvas").transform.FindChild ("BG").GetComponent<Image> ().color = currentZone.zoneColor;
  64.         }
  65.        
  66.         //Chooses a Monster then updates him to all clients
  67.         public void pickMonster()
  68.         {
  69.                 //Choose random Monster
  70.                 int monsterNum = Random.Range(0, currentZone.monsters.Count);
  71.                
  72.                 //Apply the setting to everyone
  73.                 tno.Send("monsterApply", TNet.Target.AllSaved, currentZone.monsters[monsterNum]);
  74.         }
  75.        
  76.         //Update Monster on all clients
  77.         [RFC]
  78.         public void monsterApply(string monsterName)
  79.         {
  80.                 //Get New Monster
  81.                 GameObject monsterObj = Resources.Load("Monsters/" + monsterName) as GameObject;
  82.                 Monster newMonster = monsterObj.GetComponent<Monster>();
  83.                
  84.                 //Apply Stats
  85.                 monsterSpawn.Name = newMonster.Name;
  86.                 monsterSpawn.Health = newMonster.Health;
  87.                 monsterSpawn.image = newMonster.image;
  88.                 monsterSpawn.updateMonster();
  89.                
  90.                 //Debug
  91.                 Debug.Log(monsterName + " has been spawned.");
  92.         }
  93.  
  94.         //Channel Joined Callback
  95.         void OnNetworkJoinChannel(bool success, string message)
  96.         {
  97.                 if(success)
  98.                 {      
  99.                         StartCoroutine(serverLoad());
  100.                 }
  101.         }
  102.  
  103.         IEnumerator serverLoad()
  104.         {
  105.                 //Get Monster Spawn
  106.                 monsterSpawn = GameObject.Find("Monster").GetComponent<Monster>();
  107.  
  108.                 //Delay 5 seconds
  109.                 float waitTime = TNManager.ping / 250f;
  110.                 yield return new WaitForSeconds (waitTime);
  111.  
  112.                 //Update Monster
  113.                 monsterSpawn.updateMonster();
  114.  
  115.                 //Debug
  116.                 Debug.Log ("Current Zone Name: " + currentZone.zoneName);
  117.                 Debug.Log ("Current Monster Name: " + monsterSpawn.Name);
  118.  
  119.                 //Check if zone needs to be chosen
  120.                 if(currentZone.zoneName == "Name")
  121.                 {
  122.                         //Choose a zone
  123.                         pickZone();
  124.                 }
  125.                
  126.                 //Spawn First Monster if has not been spawned yet
  127.                 if(monsterSpawn.Name == "Name")
  128.                 {
  129.                         pickMonster();
  130.                         Debug.Log("Generating First Monster....");
  131.                 }
  132.         }
  133. }
  134.  
  135. [System.Serializable]
  136. public class Zone
  137. {
  138.         public string zoneName = "Name";
  139.         public Color zoneColor = Color.cyan;
  140.         public int monstersToKill = 5;
  141.         public System.Collections.Generic.List<string> bosses;
  142.         public System.Collections.Generic.List<string> monsters;
  143. }
  144.  

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: RFC Not Received
« Reply #1 on: October 24, 2015, 05:12:22 AM »
Did you create the channel with the persistent flag set to 'true'?

WolfTechGames

  • Newbie
  • *
  • Thank You
  • -Given: 6
  • -Receive: 4
  • Posts: 35
    • View Profile
Re: RFC Not Received
« Reply #2 on: October 24, 2015, 05:22:45 PM »
Did you create the channel with the persistent flag set to 'true'?

No I didn't, I will give it a try. Another thing that I forgot to mention is that even when someone is already in the channel and a new person joins while the other is in the channel, the new person also returns name and name but I will let you know if setting true on the channel helps.

WolfTechGames

  • Newbie
  • *
  • Thank You
  • -Given: 6
  • -Receive: 4
  • Posts: 35
    • View Profile
Re: RFC Not Received
« Reply #3 on: October 24, 2015, 06:11:44 PM »
Did you create the channel with the persistent flag set to 'true'?

Thank you very much sir, that seemed to be the issue. Amazing support, love the product! :D