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 GrKl · Dec 29, 2013 at 07:06 PM · multiplayerdestroynetwork.instantiate

Network.instantiate & RPC destroy

Hello all,

Im learning slowly to work with networking. I'm now faced to the following problem:

I instantiate an 'enemy' projectile object using:

 Rigidbody instantiatedProjectile = Network.Instantiate(projectile, spawnPoint.transform.position, spawnPoint.transform.rotation, 0) as Rigidbody;    

No problem for now.

The problem is when I need to destroy this object; i've tried several solutions (including network.destroy) but the only one that seems to be working every time is:

 networkView.RPC("killEPrjt001", RPCMode.All);

 [RPC]
 void killEPrjt001()
 {
     Network.RemoveRPCs(networkView.viewID);
     Destroy (gameObject);
 }

The object is correctly deleted on both server and client, the problem is that I receive the following errors when the object is beeing destroyed:

 View ID AllocatedID: 20 not found during lookup. Strange behaviour may occur
 
 Could't invoke RPC function 'killEPrjt001' because the networkView 'AllocatedID: 20' doesn't exist

Once again, visually everything is OK, I just wonder how to destroy the object without having such an error poping every time one of these projectile is destroyed (almost every second...)

Thank you for any help possible GrKl

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

3 Replies

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

Answer by GrKl · Jan 02, 2014 at 10:11 PM

Appologies, the code given above is correct, I was actually calling twice my RPC thus it was giving me this error... sorry

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 Hunt_Dialga · Dec 30, 2013 at 01:15 PM

I'm not exactly an expert at this, but from what I can see, it looks as if you are calling the function 'killEPrjt001' after the allocatedID for that RPC function has been destroyed. ( or something like along those lines )

From my experiences with errors of destroyed objects, you should be able to just make an 'if' statement saying if the allocatedID exists then to do the function. I would show you how you could do it, but I'm not exactly anywhere good at networking.

If you cant get it to work from there I'm all out of ideas. I believe you could just leave it alone if it visually looks OK. I can see how something like this could get annoying if it persists, but I don't think the consumers would know that there is an error in the RPC networking function. And I doubt they'll care as long as the game runs fine.

I hope my "expertise" help helped.

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 inkspot · Dec 30, 2013 at 01:52 PM

I think this error is produced because both ends are detroying the object, so if the server destroys it first the client is of course unable to find it. you could try this:

  if(networkView.isMine)

or depending on your context

  if(Network.isServer) or  if(Network.isClient){
Comment
Add comment · Show 3 · 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 GrKl · Dec 30, 2013 at 03:57 PM 0
Share

Thank you both (Hunt_Dialga & inkspot)

I have indeed looked on these paths, but could'nt find any working.

If I check if network view is$$anonymous$$e, I get the same errors. If I check if network is server or client, clients or server do not destroy the object If I only check this for: Network.RemoveRPCs(networkView.viewID); but leave the destroy outside the 'IF' statement, then always the first error

I feel like I'm turning is circle...

avatar image inkspot · Dec 30, 2013 at 04:44 PM 0
Share

idk the context of the code, but is your ALL in RPC$$anonymous$$ode.All neccesary ? => RPC$$anonymous$$ODES

I had this error myself before, and the deter$$anonymous$$ing who destroys the object solved it for me with a projectile i assume that the 'shooter' knows already the info of the projectile and thus should only be send to others like RPC$$anonymous$$ode.Others I used this code for my network projectile, no [RPC] on top of the function:

 function spawnexplosion() {
 if(networkView.is$$anonymous$$ine)
 {
 Network.Instantiate(explosionparticle, transform.position, transform.rotation, 0);
  Network.RemoveRPCs(networkView.viewID);
          Network.Destroy(gameObject); 
 }}
avatar image GrKl · Dec 30, 2013 at 05:44 PM 0
Share

Yes, the 'All' is neccesary, as I do not use network.destroy, just destroy so all (clients & server) need to have this instruction to destroy their GO

your code is ok, but the problem in using network.destroy is that it is not buffered. Thus if a client joins later in the game he will instantiate all your 'explosionparticle' that were instantiated before he logged in, but he will not destroy them as he did not receive the instruction to do it

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

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

Related Questions

Tell if remote Network.Instantiate object still exists 1 Answer

destroy player cloned weapon (multiplayer 1 Answer

Don't destroy player after disconnecting or calling ClientScene.RemovePlayer() 1 Answer

Help me please with Unity Multiplayer 1 Answer

Destroy player on spawn if he already exists in scene 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