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 Omar47i · May 08, 2014 at 01:15 PM · networkingrpcnetworkview

Sending RPC to a specific client

I have a gameobject called "GlobalChat" that has a networkView attached and a Chat script that has lot of RPC functions, anyway a specific RPC function is targted to a client (the receiver of the chat entry) but when this RPC function is invoked i keep getting this two errors :

View ID SceneID: 0 Level Prefix: 0 not found during lookup. Strange behaviour may occur

and

Could't invoke RPC function 'functionName' because the networkView 'SceneID: 0 Level Prefix: 0' doesn't exist

so how can i solve this problem, i only want to call the rpc function to the specific client and this error is preventing from doing this ?!

here is a sample of the rpc function that is never called due to this error, hint: this part of code is from Chat script that is attached to an empty game object with networkView and has a scene id (not insantiated)

 // This function is called on the client when the client OnMouseDown() another player
     public void UpdateReceiverInfo(int _senderId, NetworkPlayer _receiver)
     {
         // create a receiver data structure and store receiver info
         int key = int.Parse(_receiver.ToString());
 
         if (!receivers.ContainsKey(key))        // if the key doesn't exist in the receiver array, then add the receiver and add a chat entries associated with it
         {
             // Add an entries list to this specified new receiver
             ArrayList entries = new ArrayList();                    // holds the text entries written by the connected players
             entriesArr.Add(key, entries);                           // add this entries list to the entries arr
 
             Receiver r = new Receiver();
             r.receiverId = NetworkUser.clients[key].id;              // retreive the receiver id from the static clients array
             r.receiverName = NetworkUser.clients[key].name;          // retreive the receiver name from the static clients array
             r.receiverPlayer = _receiver;                              // retreive the receiver player from the static clients array
 
             receivers.Add(key, r);                                   // append the receiver data stucture to the receivers list
         }
 
         activeRIndex = key;             // set the active client that we are currently chating with
 
         // update the sender info to the receiver
         networkView.RPC("ReceiveUpdateReceiverInfo", _receiver, _senderId, _receiver);
     }
 
     // This function is sent from a specific client that will receive the chat entry from the sender 
     [RPC]
     void ReceiveUpdateReceiverInfo(int _receiverId, NetworkPlayer _sender)
     {
         print("Entered [RPC] ReceiveUpdateReceiverInfo");        // ERROR: This line is never executed becuz of the error
         // This function is sent to the receiver client, in this case swap the process and convert the sender as receiver
         int key = _receiverId;
 
         if (!receivers.ContainsKey(key))        // if the key doesn't exist in the receiver array, then add the receiver and add a chat entries associated with it
         {
             // Add an entries list to this specified new receiver
             ArrayList entries = new ArrayList();                    // holds the text entries written by the connected players
             entriesArr.Add(key, entries);                           // add this entries list to the entries arr
 
             Receiver r = new Receiver();
             r.receiverId = NetworkUser.clients[key].id;              // retreive the receiver id from the static clients array
             r.receiverName = NetworkUser.clients[key].name;          // retreive the receiver name from the static clients array
             r.receiverPlayer = _sender;                              // retreive the receiver player from the static clients array
 
             receivers.Add(key, r);                                   // append the receiver data stucture to the receivers list  
         }
 
         activeRIndex = key;             // set the active client that we are currently chating with
     }
Comment
Add comment · Show 4
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 Paximillian · May 08, 2014 at 01:44 PM 0
Share

Are you sure you're calling it on the correct object? That it has a networkView attached? That the player is connected to the server?

A look at your script could probably help shed more light on this.

avatar image Omar47i · May 08, 2014 at 02:41 PM 0
Share

yes im calling the correct object its by the way a scene object in all players (server and client) and the players is connected to the server and this empty go has a network view with scene id, and i updated the post to include the rpc function that is never called u can look at the code.

avatar image Paximillian · May 08, 2014 at 05:35 PM 0
Share

So basically, the printf never happens?

Also, I'm not entirely sure if it has to do with this or not, but aren't you supposed to use: _receiver.networkView.RPC("ReceiveUpdateReceiverInfo", _receiver, _senderId, _receiver); on line 24?

avatar image Omar47i · May 11, 2014 at 12:01 PM 0
Share

_receiver is a NetworkPlayer instance which represents the client tht will receive the chat entries and it hasn't a networkView attached ! but thx anyway for the reply

1 Reply

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

Answer by Omar47i · May 11, 2014 at 12:50 PM

After stumbling a long time i discovered where is the problem, and i dont know y this but it seems that a connected client can't send an RPC function directly to another connected client ! i must first send it to the server and then the server will forward it to the target client, even if the client has the networkPlayer of the target client !!

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

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

Related Questions

Overloading RPCs 1 Answer

networkView not called on Child objects? 0 Answers

Networking Error! 0 Answers

OnSerializeNetworkView issus in my 2D game 3 Answers

Couldn't invoke RPC to server after Network.Destroy 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