- Home /
Network views wrong on re join to server
The clients in my game need to have net ownership of targets to prevent lag on their simulation of physics objects. (So they can be shootable and behave in a realistic manner)
This works. When a player occupies an area, they assume net ownership of the objects in that area. I accomplish that by allocating new network view id's from the players side, then sending all of those view ID's via an RPC call. Groovy.
My problem comes in when a client disconnects. When a client quits via their GUI, they first call an RPC to return net ownership to the server:
On Client:
if (GUILayout.Button("Yes") )
{
Game.m_pInstance.networkView.RPC("ReturnNetOwnershipOfStation", RPCMode.AllBuffered, m_pOwner.m_pEmbodiedSpawnPoint.m_iIndex);
StartCoroutine(DelayBeforeQuitting());
Network.Disconnect(200);
Application.LoadLevel(0);
}
On Server:
[RPC]
public void ReturnNetOwnershipOfStation(int pSpawnPointIndex)
{
if (!Network.isServer)
{
return; // Only want server to take action here
}
Debug.Log("Returning ownership of spawn index " + pSpawnPointIndex + " back to server");
SpawnPoint Station = SpawnPoint.GetSpawnPointByIndex(pSpawnPointIndex);
for (int i = 0; i < Station.m_pOwnedTargets.Count; ++i)
{
GameObject subObj = Station.m_pOwnedTargets[i].GetComponentInChildren<NetworkView>().gameObject;
NetworkViewID newViewID = Network.AllocateViewID();
networkView.RPC("UpdateGameObjectsNetworkViewID", RPCMode.AllBuffered, subObj.networkView.viewID, newViewID);
}
}
I get a runtime error saying: Couldn't send RPC function 'UpdateGameObjectsNetworkViewID'
Furthermore, when that same client re joins the server, the server spouts off a magnitude of errors looking like this:
View ID AllocatedID: 300 not found during lookup. Strange behaviour may occur Received state update for view id' AllocatedID: 300' but the NetworkView doesn't exist
Every time the client re joins, the network view ID's that they see increase by about 100. (ie they rejoin again, they get ID's in the 400 range)
What could be causing these ID's to be out of sync, and increment them like this on joining the server again?
Answer by Kyle Cavasos · May 02, 2014 at 09:25 PM
Update:
I managed to fix this with a sledgehammer approach by saying each client that joins receives the list of all network ID's that the server see's and manually sets them so they sync up
Could you please post (part of) your solution? I have the same problem, and can't figure how to get a list of all ID's neither how to manually sync.
Your answer
Follow this Question
Related Questions
How to sync networkViewIDs 0 Answers
Network Views from separate scenes causing conflicting IDs? 1 Answer
RPC or Synchronization ? 1 Answer
Where is a free, helpful tutorial on how to use Unity's networking? 2 Answers
Is server the sender of RPC? 0 Answers