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
2
Question by muppet · Apr 28, 2013 at 12:01 AM · networkingrpcnetworkviewauthoritative

Couldn't invoke RPC to server after Network.Destroy

Hi all, I'm writing a networking game using an authoritative server. My clients send their inputs to the server, the server runs the sim and sends the player positions etc back. Everything is mostly fine, except that I am getting the above mentioned errors immediately after destroying one of my players' objects by calling Network.Destroy on my server, the RPC in question is the one used to send inputs to the server, and is called in the client's Update function.

The update code:

 public void Update () {
     if (Network.player == owner) {
         updateInputs();
         if (Network.isClient && Globals.playerState == Globals.PlayerState.ALIVE) {
             //send input to server
             _networkView.RPC("sendInput", RPCMode.Server, yaw, pitch, roll, throttle, gearState, fire1, fire2);
         }
     }
 }

The code called when the player takes damage:

 public void damage(float damage) {
     if (Network.isServer) {
         health = Mathf.Max(health - damage, 0f);
         if (health == 0f) {
             _networkView.RPC("die",RPCMode.AllBuffered);
             Network.RemoveRPCs(_networkView.viewID);
             Network.Destroy(gameObject);
         }
     }
 }

The "die" RPC:

 [RPC]
 public void die() {
     if (Network.player == owner) {
         Globals.playerState = Globals.PlayerState.DEAD;
     }
     <other cosmetic stuff happens here>
 }

It would appear that Network.Destroy executes too quickly on the server after the RPC call to "die" is triggered, which cannot quickly enough prevent the client from trying to call "sendInput". However, the networkView has already been destroyed on the server and I get the error:

Could't invoke RPC function 'sendInput' because the networkView 'AllocatedID: X' doesn't exist

Any ideas on how to prevent this?

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 Nims · Apr 15, 2014 at 09:24 AM 0
Share

Wondering if you ever got this solved...as I am facing similar problems. I don't think the explanation you give here is th actual source of the problem. The problem in my opinion is that as you destroyed the player game object on the server, the player game object still exists in the players game instance sending data (until the order to destroy this player is reached from the server). So you are still generating network traffic with no networkview to receive it on the server side. It seems the only way to fix this would be to destroy the gameObject sending the data first and destroying it on the server later. But I need to test this hypothesis.

0 Replies

· Add your reply
  • Sort: 

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

14 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

Related Questions

Networking Error! 0 Answers

OnSerializeNetworkView issus in my 2D game 3 Answers

Overloading RPCs 1 Answer

RPC not sending and not giving an error? 0 Answers

getting error with networkView 0 Answers


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