- Home /
Networking GameManager/GameState Sync
Hello Everyone,
I am new to Unity Networking and networking in general. I have a prototype game I created and would like to add in multiplayer. My issue is that I currently have a GameManager that controls and stores all the info for the current game. When I have a client connect to my host, the client GameManager does not have the correct game info and do to the lack of variable types RPC's can send I don't know of a way to fill out the client side GameManager's info.
I would like to know if there is a way I can transfer my GameManager data to the clients or if there is a way I can just access the server GameManager and not worry about the clients manager at all.
Thank you in advance and if you need more info on this problem please ask.
Answer by nastasache · Jan 09, 2014 at 11:47 AM
I think the way is to adapt some GameManager variables to be compatible with RPC's variables types. By my experience RPC's variables types are enough for any logical needs. I am using something similar and all works well; when a RCP type doesn't exist I simple store lists with integer index, send index with RPC and read and apply values on targets by the integer index.
Hey Nastasache,
Thanks for the reply, I did try this out on my own but I cant seem to get it correct.
I have a List of GameObjects(tile$$anonymous$$ap) that have a script attached to them. They all have a NetworkView attached and are set to reliable.
I created an RPC that will send over the viewID and just for now the tileID for each tile.
networkView.RPC ("SetTiles", RPC$$anonymous$$ode.AllBuffered, floorList[index].networkView.viewID, floorList[index].GetComponent<FloorCubeScript1>().floorID);
Then on the client side when I receive the call I get all tile objects in the scene and check for the matching viewID's.
[RPC]
void SetTiles(NetworkViewID viewID, int floorID){
GameObject[] floor = GameObject.FindGameObjectsWithTag ("Floor");
GameObject go = null;
FloorCubeScript1 newTile, oldTile = null;
for(int index = 0; index < floor.Length; ++index){
if(floor[index].networkView.viewID == viewID)
{
go = floor[index];
go.GetComponent<FloorCubeScript1>().floorID = floorID;
floorList.Add (go);
}
}
}
The issue now is that I can not access the client sides tile script member vars to set them up with the server side info that i am passing over.
I get a $$anonymous$$onoDev. error:
Any help would be appreciated. Thank you.
I never saw this error. Looks related with virtual machines. Do you have installed Unity on a V$$anonymous$$? As your your code, I see no reason not to work.
No I do not run on a V$$anonymous$$. This is really bothering me as I thought this should work and your answer reaffirmed that but this is beyond me.
Your answer
Follow this Question
Related Questions
How To Deal With Lingering Prefabs in Multiplayer Scene ? 0 Answers
SyncVar issue 0 Answers
[Error] RPC function undefined in IRRELEVANT file? 0 Answers
Unity networking tutorial? 6 Answers