Correct way to Network.Destroy(gameObject) ??

I Network.Instantiate a RPG with -

var projectile = Network.Instantiate(RPG, transform.position, transform.rotation, 0);

Then within the script attached to the RPG I have code to destroy the gameObject 2 seconds after it has hit the ground with -

networkView.RPC("killRPG", RPCMode.AllBuffered);
 
@RPC
function killRPG(){
 
    Destroy(gameObject);
}

But the problem is sometime I get the error - View ID AllocatedID: 156 not found during lookup. Strange behaviour may occur I presume that a package gets through to the server before the gameObject is destroyed, is there a better way of destroying the gameObject over the network ?

I’ve also tried -

Network.Destroy(gameObject);

With the same results.

when you instantiate, you add for example on group 1.

 Network.Instantiate(fireball_prefab, weapon.position, rot, 1);

You can destroy the gameobject on each current player and futur player.

private void destroy_me()
    {
        if (networkView.isMine)
        {
            Network.RemoveRPCsInGroup(1);
            Network.Destroy(gameObject);
        }
    }
1 Like

Thank you for the input, much appreciated …

I am very interested to know if this actually worked for you Griffo.
As I am having very similar problems:
I have a player gameObject which is Netwrok instantiated by the client. This player gameObject transmits data via RPC’s to the server).
When i destroy this object on the server, the player gameObject is still transmitting data to the server, until the command is reached to the client’s game instance to destroy this object.
The problem is that during this time a situation arises where the player gameObject is transmitting data while on the server it’s already destroyed, giving rise to “Couldn’t invoke RPC error” on the server itself.

I have seen a similar posts with no real answers to this issue:
http://answers.unity3d.com/questions/446083/couldnt-invoke-rpc-to-server-after-networkdestroy.html

Any solutions to this?
How would you go about destroying an object on the server side while it is transmitting data to the server from the client?

The machine that spawned/ownes the object (usually the server) needs to perform the delete to keep it from updating other machines that would have already deleted their local copy otherwise. This could be done without significant changes to existing code by clients sending a ‘DestroyRequest’ message to the server and having the server call Network.Destroy rather than calling it directly on the client.