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 Sickuhtrix · Jan 30, 2014 at 11:17 PM · networkinginstantiateaidestroy

Proper/Best way to Instantiate and Destroy with Unity Networking?

So, to make this straight forward, I'm trying to "drop loot" over the network, and I need the call to be buffered, because when people join a server, they obviously need to be aware of the loot that has been dropped.

Now, I have tried every different way I can possibly think of, to do this right.

I ALWAYS get unallocated errors, somewhere, eventually, somehow. Some methods I've tried have held off on the errors for a lot longer than others, but it always still appears, and sometimes it does cause strange behavior (such as loot disappearing as soon as it's dropped, etc etc).

I also need a proper way to destroy the AI. Right now, the server uses Network.Instantiate to spawn the AI, so the AI is owned by the server player.

The loot is also uses Network.Instantiate when I call it to "drop" from the monster.

But loot can also be "dropped" from players from their inventory, (uses the same prefab as loot dropped from monsters).

Loot dropped from Player Inventories uses Network.Instantiate as well.

But whenever I try to destroy these objects, I'm always getting errors. I'm not sure the best way to destroy stuff.

I know Network.Destroy isn't buffered, but if I try to call it in an buffered RPC, it leads to the same error.

I've tried so many different methods, using networkView.isMine when using Network.Destroy. I've tried using Network.RemoveRPCs(this.networkView.viewID) before destroying, after destroying, and just I've tried everything I can think of with every thing.

When loot is destroyed, it's destroyed in the same script, I don't call upon another script to destroy the object. (if that matters at all). Same with the AI.

Should I be Instantiating a different way? Through RPCS? Even when I do Instantiate through RPC's, I still get errors.

What is the best way to Instantiate and Destroy and object, and avoid all the "AllocateID" errors, and "couldn't receive RPC FunctionNameHere because AllocatedID IDHERE couldn't be found" etc etc.

It baffles me I've sat here literally for 15 hours or so and still can't figure out something SO SIMPLE. I just feel stupid at this point, and I can't even work on other parts of the project because this is bugging me so damn much and it's pretty key to my game.

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
1

Answer by Sickuhtrix · Jan 31, 2014 at 05:57 AM

Alright, for anyone with the same problem, I FINALLY FOUND A SOLUTION.

This is what I am calling on every object that I use Network.Instantiate with.

     void DestroyGO(){
         RemoveBufferedInstantiate (this.networkView.viewID);
         Network.Destroy (this.gameObject);
     }
     
     
     [RPC]
     void RemoveBufferedInstantiate (NetworkViewID viewID) {
         if (Network.isServer) {
             Network.RemoveRPCs (viewID);
         } else {
             networkView.RPC ("RemoveBufferedInstantiate", RPCMode.Server, viewID);
         }
     }

On any object you want to destroy, just call:

DestroyGO();

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
avatar image
0

Answer by Punkjim420 · Jan 30, 2014 at 11:55 PM

maybe this? http://docs.unity3d.com/Documentation/ScriptReference/Network.Instantiate.html

Comment
Add comment · Show 2 · 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 Sickuhtrix · Jan 31, 2014 at 01:22 AM 0
Share

I don't want to be rude but you clearly didn't read my question.

avatar image Punkjim420 · Feb 07, 2014 at 02:29 PM 0
Share

Actually i did, but it was very late, so i wasnt thinking clear. sorry about that.

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

19 People are following this question.

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

Related Questions

Can a Network.Instantiate()'d object be Object.Destroy()'d? 0 Answers

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

Instantiated GameObject being deleted when destroying original 1 Answer

Object wont object get destroyed 1 Answer

Kill character on impact 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