Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 11 Next capture
2021 2022 2023
1 capture
11 Jun 22 - 11 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 thornekey · Aug 12, 2015 at 02:25 PM · c#serverrpcnetworkview

RPC to server from client

Im trying to send the player's username and password from the client to the server (then to the database which i have done successfully). On the client game controller I have this when the player attempts to log in:

 GetComponent<NetworkView>().RPC("AuthLogin", RPCMode.Server, username, password);
 //network.RPC() <- seems to obsolete, but oh well.
  

and then on my server controller I have this:

 [RPC]
 void AuthLogin(string user, string pass) {
     Debug.Log(user + ":" + pass);
 }

It seems that its trying to look for the RPC function in the client's controller.. How do I make it send it to the server?

Here is the error:

RPC call failed because the function 'AuthLogin' does not exist in the any script attached to'C_controller'

Comment
Add comment · Show 2
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 ali_asif · Aug 12, 2015 at 03:49 PM 0
Share

can you show the code where you're connecting to server ?

avatar image thornekey · Aug 13, 2015 at 01:11 AM 0
Share

Im just connecting with the standard`Network.Connect(...);`

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Wiki

Answer by NathanHold · Aug 14, 2015 at 12:41 PM

RPC does a Remote Procedure Call on the GameObject your script is currently on.

For this you should have a single NetworkController GameObject which either the Client or Server controller scripts are on or a complete NetworkController script that handles both client and server code. You could also have both GameObjects and scripts exist on client and server and get the NetworkView of the server GameObject and RPC call on that.

If you don't want to do any of that you'll have to create your own RPC library.

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 thornekey · Aug 15, 2015 at 08:49 AM 0
Share

thanks for a solution. my reason being is because i have a database and i dont want the client to directly access the database. I want the client to call an RPC in the server and the server can handle the database request..

avatar image Bunny83 · Aug 15, 2015 at 09:34 AM 0
Share

@thornekey: It's enough if the client script has an RPC method with the same signature (name and parameters). The method can be empty but it has to be there ^^. I've once done the same thing and seperated the client and server logic into seperate scripts. At the bottom of each script i had a block of empty RPC definitions for the other side just to make them work.

$$anonymous$$eep in $$anonymous$$d that you're using Unity's old Network system (RakNet). Unity now has a new networking system (UNet) which is more powerful but also slightly more complicated.

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

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

Related Questions

RPC not being called 1 Answer

Network how to send data/activate function 1 Answer

How can I send a mouse click to a server using an RPC? 0 Answers

Generic RPC Call 1 Answer

Multiple Cars not working 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