Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by SomeGuy22 · Jul 30, 2012 at 06:49 PM · networkinginstantiatemultiplayernetworkdestroy

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); 
  }
 
  
  }
 }
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image nevaran · Dec 04, 2013 at 07:50 PM 0
Share

Hey! the rpc group one looks pretty promising, but the documentary does not really tell what the ID int is all about. I have tried with this code:

Network.RemoveRPCsInGroup(networkView.viewID);

and a few others, but nothing seems to work. Any help?

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by ScroodgeM · Jul 30, 2012 at 07:32 PM

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

Comment
Add comment · Show 10 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SomeGuy22 · Jul 30, 2012 at 08:51 PM 0
Share

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?

avatar image ScroodgeM · Jul 30, 2012 at 08:54 PM 0
Share

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

look for 'group' variable

avatar image SomeGuy22 · Jul 30, 2012 at 09:45 PM 0
Share

But won't that remove all the mobs rpcs?

avatar image ScroodgeM · Jul 30, 2012 at 09:47 PM 0
Share

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

avatar image SomeGuy22 · Jul 30, 2012 at 10:16 PM 0
Share

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

Show more comments
avatar image
0

Answer by Minchuilla · Apr 16, 2014 at 05:06 PM

For the purpose of more recent viewers:

To create a gameObject across the network use Network.Instantiate this includes a buffer so any client joining after the gameObject was instantiated will also have the gameObject instantiated.(note: this is in the form of a buffered RPC)

Network.Destroy destroys the gameObject on all players that are currently connected, however, this does not include a buffer. So a client joining after the deletion of the object will still have a copy of it.

To remove this copy use the code below:

 Network.RemoveRPCs(networkView.viewID);
 Network.Destroy(gameObject);

This code then removes the RPC to instantiate the gameObject for newer clients and then destroys the gameObject for all current users.

note: the gameObject does not need a networkView component attached to it for this to work.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How can I spawn a GameObject on all players in my multiplayer game? 0 Answers

Network.Instantiate is CHAOS. 1 Answer

Unity networking tutorial? 6 Answers

Players Not Showing 0 Answers

Multiplayer|3dText PlayerName 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges