Proper/Best way to Instantiate and Destroy with Unity Networking?

So, to make this straight forward, I’m trying to “drop loot” over the network, and I need the call to be buffered, because when people join a server, they obviously need to be aware of the loot that has been dropped.

Now, I have tried every different way I can possibly think of, to do this right.

I ALWAYS get unallocated errors, somewhere, eventually, somehow. Some methods I’ve tried have held off on the errors for a lot longer than others, but it always still appears, and sometimes it does cause strange behavior (such as loot disappearing as soon as it’s dropped, etc etc).

I also need a proper way to destroy the AI. Right now, the server uses Network.Instantiate to spawn the AI, so the AI is owned by the server player.

The loot is also uses Network.Instantiate when I call it to “drop” from the monster.

But loot can also be “dropped” from players from their inventory, (uses the same prefab as loot dropped from monsters).

Loot dropped from Player Inventories uses Network.Instantiate as well.

But whenever I try to destroy these objects, I’m always getting errors. I’m not sure the best way to destroy stuff.

I know Network.Destroy isn’t buffered, but if I try to call it in an buffered RPC, it leads to the same error.

I’ve tried so many different methods, using networkView.isMine when using Network.Destroy. I’ve tried using Network.RemoveRPCs(this.networkView.viewID) before destroying, after destroying, and just I’ve tried everything I can think of with every thing.

When loot is destroyed, it’s destroyed in the same script, I don’t call upon another script to destroy the object. (if that matters at all). Same with the AI.

Should I be Instantiating a different way? Through RPCS? Even when I do Instantiate through RPC’s, I still get errors.

What is the best way to Instantiate and Destroy and object, and avoid all the “AllocateID” errors, and “couldn’t receive RPC FunctionNameHere because AllocatedID IDHERE couldn’t be found” etc etc.

It baffles me I’ve sat here literally for 15 hours or so and still can’t figure out something SO SIMPLE. I just feel stupid at this point, and I can’t even work on other parts of the project because this is bugging me so damn much and it’s pretty key to my game.

maybe this?

Alright, for anyone with the same problem, I FINALLY FOUND A SOLUTION.

This is what I am calling on every object that I use Network.Instantiate with.

	void DestroyGO(){
		RemoveBufferedInstantiate (this.networkView.viewID);
		Network.Destroy (this.gameObject);
	}
	
	
	[RPC]
	void RemoveBufferedInstantiate (NetworkViewID viewID) {
		if (Network.isServer) {
			Network.RemoveRPCs (viewID);
		} else {
			networkView.RPC ("RemoveBufferedInstantiate", RPCMode.Server, viewID);
		}
	}

On any object you want to destroy, just call:

DestroyGO();