Hey all,
I've stumbled across an odd problem and can't seem to figure out whats going on here...
I need the ability to switch out part of my game logic at runtime into game modes (eg deathmatch, team deathmatch, capture the flag etc)
So here's a simplified version of the setup :
GameManager :
Contains core game logic and functionality that would be shared across all game modes.
Setup directly in the scene, with a TNO for network communication.
GameManager Script :
public GameObject[] gameModePrefabs; //Drag gameMode prefabs here in the editor
private GameObject mGameMode;
void Start()
{
if(TNManager.isHosting)
tno.Send("StartGameMode", Target.AllSaved, 0); // 0 should really be the index/ID of the gameMode you want to instantiate
}
[RFC]
void StartGameMode(int modeID)
{
mGameMode = Instantiate(gameModePrefabs[modeID]) as GameObject; // Yes, that is the unity Instantiate, but the prefab has a TNObject on it with the ID set manually
}
GameMode :
Contains logic and functionality specific to the gameMode.
NOT in the scene at startup, but instead stored as a prefab. Also has a TNObject with a manually set id (1000).
GameMode Script :void Start()
{
if(TNManager.isHosting)
tno.Send("TestMessage", Target.AllSaved, "Message Received!");
}
[RFC]
void TestMessage(string msg)
{
Debug.Log(msg);
}
What happens? :
Well, as the server, everything works as it should. The 'gameMode' is instantiated and the server get's the Debug.Log message.
Connecting as a client : the client gets the saved RFC to instantiate the 'gameMode' but, the saved RFC for the debug message doesn't trigger.
The strange thing is, the TNObjects on the runtime instantiated 'GameModes' do communicate (if you send a new message afterwards, it comes through as expected. it seems it's only the saved/buffered calls that don't get passed through for some reason...)
Any ideas as to whats happening here?
Cheers!
Update :
After doing a bit of poking around in the TNObject class, it looks like the client does in fact receive the "TestMessage" saved RFC... but before the TNObject has been registered.
It seems what happens is that the RFC call gets added to the delayed call list (mDelayed) until the corresponding TNObject exists/registers. But for some reason, these calls don't get excecuted even after the tno registers itself....