How can I delete or destroy an instance of an object IN A MULTIPLAYER GAME?.

How can I delete or destroy an instance of an object IN A MULTIPLAYER GAME?.

I know how to do this in a singleplayer game, but I need to know how to do this in a multiplayer game. What else I need?.

I can instantiate in the right way and I can watch in the server and client version…But the destruction is my problem: My rainbow can’t be destroyed. :frowning:

My code is based on the tutorial called “M2H_Networking_Tutorial”:

And my code is:

var rainbow:GameObject;
var rainbow_sound: AudioClip;

private var activate_rainbow:boolean=false;

var timer : float = 2;

function Awake () {
timer = Time.time;
}
function Update () {

    
//Called on the server only
	if(Network.isServer)
	{	
	
		if (global_counter.activate_rainbow==true)
		{
			var myNewTrans : Transform = Network.Instantiate(rainbow, transform.position, transform.rotation,0) as Transform;
			global_counter.activate_rainbow=false;
			//Get the networkview of this new transform
			
			var newObjectsNetworkview : NetworkView = myNewTrans.networkView;
	 		    				
			//Network.Destroy(myNewTrans,10);
			if (Time.time - timer > 2) 
			{
				Network.Destroy(gameObject);
			}
		}
	}
}

Any suggestion?. Thank you in advance.

hi: I just have watched this in teh official manual reference:

Behind the scenes, Network Instantiate is simply a convenience function built around RPC calls. It serializes an identifier of the prefab that is to be instantiated, serializes all allocated NetworkViewID’s, serializes the position, and send it across the network using an RPC call. Network.Instantiate() will always buffer the Instantiate call in the RPC buffer, this also means it can be removed from the buffer in the same way as other RPC calls.
In essence this is a regular instantiation that is performed on all clients and automatically buffered. Players that join after the instantiation was performed will also receive the Instantiate call.

So, maybe I should remove all the buffered RPCs because internally Network.Instantiate works as a RPC sentence…What do you think about it?.

Thank you in adavance.

The fact is that I can destroy an existing object but no an instanciated object…Or maybe the timers I use…Using timers for destroying objects use to be complicated…I don’t know what can be my problem…