I have purchased and gone through the tutorial, as well as reading everything I can on the forums but I still have a few things I don’t understand.
First, I don’t see a good simple yet complete example of how to NOT use Network.Instantiate. All the tutorials use this, and then the guide says don’t use this. Most of the forum posts say not to use it as well, though never really explaining why. When I use it I get working networked objects, but nothing deletes on the server when clients disconnect, so I’m assuming thats the problem with it, but I don’t know.
Has anyone put together a step by step guide of network code only to explain how to do start using the non Network.Instantiate method? I tried remaking the steps from the tutorials without it but my client fails when it receives the RPC I am calling to instantiate my prefab client side because the prefab has no networkview ID yet. (At least I think that is what the error means)
Basically this is what I am doing, but I must be missing a step client side. (skipping all non network code to make this simple)
//SERVER
Network.InitializeServer(32,connectPort,false);
//CLIENT
Network.Connect(connectToIP, connectPort);
//SERVER
void OnPlayerConnected(NetworkPlayer player)
{
NetworkViewID viewID = Network.AllocateViewID();
//call instantiate on my prefab and add it to a list of players serverside (not Network.Instantiate)
networkView.RPC(“SpawnPlayerPrefab”, RPCMode.OthersBuffered, viewID, transform.position); //create the ship on all the clients manually because not using Network.Instantiate
}
//CLIENT
//spits out debug.log receive RPC debug message but my SpawnPlayerPrefab RPC is never called
//instead I get the following 2 errors;
View ID SceneID: 1 Level Prefix: 0 not found during lookup. Strange behaviour may occur
Could’t invoke RPC function ‘SpawnPlayerPrefab’ because the networkView ‘SceneID: 1 Level Prefix: 0’ doesn’t exist
It seems I need to create the network view client side first somehow, but I don’t know how else to tell the client about the network view ID the server just created other then the RPC I am using now, and I don’t know where else I would assign this view id to until I instantiate the prefab on the client which contains the network view for that object.
Thanks!