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 ODNSEV7N · Nov 26, 2013 at 12:23 PM · rpc

Simple example of an RPC message?

Hey, I am at the point where I need to think about what the user sees when he/she is connected to a server.

If I could get some info on maybe how to just get it to spit out "john" connected. then I could figure the rest out, the doc's are a tad hard to understand for a beginner. (John is a saved PlayerPref) (This Doc)

Cheers,Tim.

I know it's @RPC..something something heheh

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 KiraSensei · Nov 26, 2013 at 12:39 PM 0
Share

What do you really want to do ?

Do you need a client to tell the server its name ? Or something else ?

avatar image ODNSEV7N · Nov 26, 2013 at 02:49 PM 0
Share

Well when someone connects, they just connect. I want the server to to tell everyone that "kira" connected. Or if theres a few people on, I want them to be able to distinguish between "kira, the person who doesnt crash everyone" and "bob,the person who crashes everyone.

Once I figure out that..I plan to display peoples name along with their ping. And some other things. Perhaps for clan na$$anonymous$$g as well.

The nickname must be picked before the user can get online, once the name is picked it's saved in a playerpref. And then the user can get online. But no one sees their name.

Hope I explained it better (:

1 Reply

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

Answer by KiraSensei · Nov 26, 2013 at 03:08 PM

So first you need your client to tell the server who he is :

 function OnConnectedToServer ()
 {
     var name:String = PlayerPrefs.GetString("Player Name");
     networkView.RPC("TellNameToServer", RPCMode.Server, name, Network.player);
 }

Then you need your server to handle the info (stock it locally if you want for example in a list of players) and tell every client who just connected :

 @RPC
 function TellNameToServer(name:String, thisPlayer:NetworkPlayer) {
     networkView.RPC("DisplayName", RPCMode.AllBuffered, name);
 }

And after that you need every player to handle this info (like stock it too, or display it in your case) :

 @RPC
 function DisplayName(name:String) {
     // Here you display the name, I don't know how you plan to do that, so you're on your own :)
 }

All these functions are in the same script, every player must have it.

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

17 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

Related Questions

How to get NetworkPlayer? 2 Answers

Does the position change need state synchronization? 2 Answers

Serialize a LineRenderer 2 Answers

NetworkMessageInfo sender.guid set to empty string "" or "0"? 1 Answer

Problem with Playmaker Send Remote Event 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