Hey guys,
I have been chasing this problem for a few days now. In fact there is a post of mine on the forums where I blame Network.Destroy for all my troubles. The truth of the matter is that I didn’t fully understand it as it didn’t rear its head every time I expected it too. When you write code, you expect it to work or not to work. Anyway on to the problem…
I build ships, ships can build projectiles to shoot at other ships. When I start a server for the first minute everything is fine. However, I have noticed that I reach a point after this first minute where I start encountering “NetworkView doesn’t exist”. If it is a Client created object, these errors appear on the Server, similarly, if it is server owned these messages appear on the client.
View ID AllocatedID: 54 not found during lookup. Strange behaviour may occur
Received state update for view id’ AllocatedID: 54’ but the NetworkView doesn’t exist
By enabling Network debugging to full have determined that this happens once my Client VeiwIDs enter into the 50+ plus range. I’m getting the impression that my server thinks after 60 seconds “okay this guy needs some view IDs to pool from, here you go” - but none of them work from this point forward. Actually they throw that particular error but often they also leave an objects state unchanged on one system. It doesn’t seem to matter how I allocate them either. I have projectiles manually allocated, and ships instantiated with Network.Instantiate. I did this to draw a comparison.
Some code then, right when my ships receive a target they call the following:
function fireWarhead(go : GameObject)
{
if(armNuke)
{
targetEnemy = go;
if(networkView.isMine)
{
var viewID = Network.AllocateViewID();
networkView.RPC("SpawnNuke", RPCMode.All, viewID);
}
}
armNuke = false;
}
@RPC
function SpawnNuke (viewID : NetworkViewID)
{
// Instantate the prefab locally
newNuke = Instantiate(nuke, transform.position, transform.rotation);
var nView : NetworkView;
nView = newNuke.GetComponent(NetworkView);
nView.viewID = viewID;
if(networkView.isMine)
{
newNuke.GetComponent(homingMissile).setTarget(targetEnemy); //position is in sync on owner
}
}
Any ideas, suggestions or abuse? The fault is undoubtedly mine, however given that the earliest allocated viewIDs seem fine with both parties - it looks a lot like unity’s network handler is dropping the ball.