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 jorgon · Nov 03, 2011 at 12:23 PM · multiplayernetworkdestroyinstancenetwork.destroy

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

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.

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by jorgon · Nov 07, 2011 at 10:29 AM

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.

Comment
Add comment · Show 4 · 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 syclamoth · Nov 07, 2011 at 10:59 AM 0
Share

When I started using Unity Networking, I used Network.Instantiate for everything because it was convenient- until I realised where the harrowing bulletstorm I was putting new players through whenever they joined the game was co$$anonymous$$g from...

avatar image jorgon · Nov 07, 2011 at 12:01 PM 0
Share

And how did you solve this?. What did you do with it?. Could you help me?. I'm not instantiating players...I'm instantiating objects.

avatar image syclamoth · Nov 07, 2011 at 12:18 PM 0
Share

Well, I stopped using Network.Instantiate. I ins$$anonymous$$d use a fairly complex web of RPC calls, which passes around NetworkViewIDs. I take advantage of the fact that once a NetworkViewID has been allocated by the Network, it doesn't have to get assigned to a networkView immediately- you can do that manually if you so choose. Look up Network.AllocateViewID in the reference, there's a good example of how to use it.

avatar image jorgon · Nov 09, 2011 at 12:35 PM 0
Share

Please, could you copy any link to any tutorial?. I need to watch an example...

This is my actual state: http://forum.unity3d.com/threads/111237-How-to-destroy-objects-in-a-multiplayer-game?p=738454#post738454

avatar image
0

Answer by jorgon · Nov 10, 2011 at 09:49 AM

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

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Player not deleting on server exit 1 Answer

How to properly destroy non-instantiated objects over a network? 1 Answer

Network.Destroy(), Couldn't perform remo 0 Answers

Network RPC buffer issue 0 Answers

Tell if remote Network.Instantiate object still exists 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