x


Network.Destroy doesn't remove objects on other systems?

When I network.Instantiate a mob on one computer, and another computer logs in, the object is where it should be. However, if that mob is destroyed with network.Destroy, and another computer logs in, the other computer still sees that mob.

What am I doing wrong?

(This is the important parts of the spawner code)

function OnNetworkLoadedLevel ()
{

 yield;
 yield;
 yield;

 if (!hasOne)
 {
 hasOne = true;
 networkView.RPC("StartSpawningrpc", RPCMode.All);
 }

 else
 Destroy(gameObject);
}
@RPC
function StartSpawningrpc ()
{
 //Debug.Log("Made it here???");
 for (var i = 0; i >= 0; i++)
 {
 yield WaitForSeconds (wait);
 var i2= Random.Range(-30, 30)* range;
 var j= 50;
 var k= Random.Range(-30, 30);
 var pos=Vector3(i2,j,k);
 //Debug.Log("Made it here!");

 if (amount < maxAmount)
 {
 amount++;
 Network.Instantiate (enemy, pos, Quaternion.identity, 0); 
 }


 }
}
more ▼

asked Jul 30 '12 at 06:49 PM

SomeGuy22 gravatar image

SomeGuy22
174 4 6 9

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

Network.Instantiate is buffered call Network.Destroy is not.

so, if you join the scene after instantiate-destroy was called, you got only instantiate call and see the object. just clear buffer after destroying for future joins

http://docs.unity3d.com/Documentation/ScriptReference/Network.RemoveRPCs.html http://docs.unity3d.com/Documentation/ScriptReference/Network.RemoveRPCsInGroup.html

more ▼

answered Jul 30 '12 at 07:32 PM

ScroodgeM gravatar image

ScroodgeM
7.6k 2 6

Do remove the rpcs of the destroyed object? The reference says remove for a network player but it is not a player. Do I have to trick it into thinking the mob is a player somehow?

Jul 30 '12 at 08:51 PM SomeGuy22

But won't that remove all the mobs rpcs?

Jul 30 '12 at 09:45 PM SomeGuy22

use group for object you want totally clean. this will not remove all the mobs rpcs from OTHER groups

Jul 30 '12 at 09:47 PM ScroodgeM

So I have to change the group of one mob when it dies. How do I change the group?

Jul 30 '12 at 10:16 PM SomeGuy22
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1680
x764
x710
x702
x682

asked: Jul 30 '12 at 06:49 PM

Seen: 638 times

Last Updated: Jul 30 '12 at 10:54 PM