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 Guardian2300 · Mar 04, 2014 at 05:41 PM · networkingrpcdata

Sending Data through RPC

Hello, some reason If I understood the page for rpc's correctly, you should be able to send certain kinds of data to other clients or servers, (int, float, string) but some reason when I try to send the data to the other clients and server, it completely ignores to tell everyone the max players for the game.

Here is my code example

     void OnPlayerConnected()
     {
         networkView.RPC("AddPlayer",RPCMode.AllBuffered,TotalPlayers);
     }
     void OnPlayerDisconnected(NetworkPlayer aPlayer)
     {
         networkView.RPC("RemovePlayer",RPCMode.AllBuffered,TotalPlayers);
         Network.RemoveRPCs(aPlayer);
         Network.DestroyPlayerObjects(aPlayer);
     }

and these are the RPC's that I'm calling when the player connects or disconnects

     [RPC]
     void AddPlayer(int Total)
     {
         TotalPlayers = Total + 1;
         Debug.Log("Sent"+TotalPlayers);
     }
     [RPC]
     void RemovePlayer(int Total)
     {
         TotalPlayers = Total - 1;
     }

is there something I'm doing wrong or missing or does there seem to be a bug. I've been trying to do this for awhile now and help on this if its impossible or something I'm not doing correctly

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
Best Answer

Answer by Guardian2300 · Apr 02, 2014 at 05:20 PM

Solved the string array also, I created one string from the array of strings and sent into the rpc string variable i created and then I split them up after they were retrieved.

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 paskal007r · Mar 15, 2014 at 06:17 PM

Did you check that the RPC is actually sent?

Most of the times I had a similar problem it was because of issues with the networkview (networkViewId not matching on objects generated at runtime on different instances or no networkview attached to the object at all).

Also, are the rpc's and the onPlayerConnected on the same object? If not the problem might be that you should call the rpc on the networkview of the object with the rpc functions.

Comment
Add comment · Show 1 · 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 Guardian2300 · Apr 02, 2014 at 04:21 PM 0
Share

I solved it but now another question with sending data through rpc, is it possible to send a string array through the rpc function?

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

Networking When Offline 1 Answer

Which is better: NetworkView or RPC? 1 Answer

RPC failed to send 1 Answer

Photon Network Instantiate Objects over Network 1 Answer

unity c# RPC 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