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.
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.