Network.instantiate & RPC destroy

Hello all,

Im learning slowly to work with networking. I’m now faced to the following problem:

I instantiate an ‘enemy’ projectile object using:

Rigidbody instantiatedProjectile = Network.Instantiate(projectile, spawnPoint.transform.position, spawnPoint.transform.rotation, 0) as Rigidbody;	

No problem for now.

The problem is when I need to destroy this object; i’ve tried several solutions (including network.destroy) but the only one that seems to be working every time is:

networkView.RPC("killEPrjt001", RPCMode.All);

void killEPrjt001()
	Destroy (gameObject);

The object is correctly deleted on both server and client, the problem is that I receive the following errors when the object is beeing destroyed:

View ID AllocatedID: 20 not found during lookup. Strange behaviour may occur

Could't invoke RPC function 'killEPrjt001' because the networkView 'AllocatedID: 20' doesn't exist

Once again, visually everything is OK, I just wonder how to destroy the object without having such an error poping every time one of these projectile is destroyed (almost every second…)

Thank you for any help possible

I’m not exactly an expert at this, but from what I can see, it looks as if you are calling the function ‘killEPrjt001’ after the allocatedID for that RPC function has been destroyed. ( or something like along those lines )

From my experiences with errors of destroyed objects, you should be able to just make an ‘if’ statement saying if the allocatedID exists then to do the function. I would show you how you could do it, but I’m not exactly anywhere good at networking.

If you cant get it to work from there I’m all out of ideas. I believe you could just leave it alone if it visually looks OK. I can see how something like this could get annoying if it persists, but I don’t think the consumers would know that there is an error in the RPC networking function. And I doubt they’ll care as long as the game runs fine.

I hope my “expertise” help helped.

I think this error is produced because both ends are detroying the object, so if the server destroys it first the client is of course unable to find it. you could try this:


or depending on your context

if(Network.isServer) or  if(Network.isClient){

Appologies, the code given above is correct, I was actually calling twice my RPC
thus it was giving me this error… sorry