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 epicVoodoo · May 28, 2015 at 08:59 AM · multiplayerplayernetworkrpcname

Displaying players name above in multiplayer

Hi!

In my game, every player has a child GameObject called "NameAbove" which contains GUIText component. Here's my code:

 //class Player
 void Update()
 { 
     //if(networkView.IsMine)
     if (dataSet && !nameSet)
     {
         SetNameAbove(this.characterName); // i've tried also RPC - no result
     }
  }
        
     [RPC]
     void SetNameAbove(string n)
     {
 gameObject.transform.FindChild("NameAbove").GetComponent<GUIText>().text = n;
         nameSet = true;
     }

So i need every player to display his own name having set it to his child GO in GUIText component.

Thanx in advance.

Comment
Add comment · Show 6
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 Hellium · May 28, 2015 at 09:07 AM 0
Share

Could you explain a little bit more what your problem really is ?

The text is not visible ? The text doesn't change ? Please, give details, we are not wizards.

avatar image epicVoodoo · May 28, 2015 at 11:27 AM 0
Share

That's how i get player nickName;

void Update() {

         if (networkView.is$$anonymous$$ine) // here we recieve $$anonymous$$Y player name
         {
             if (!dataSet && myPlayerdata.Length > 0)
             {
                 networkView.RPC("AdjustPlayerDataOnEnterWorld",                RPC$$anonymous$$ode.All, this.networkView.viewID);
             }
         }
 }
 
     [RPC]
     public void AdjustPlayerDataOnEnterWorld(NetworkViewID id)
     {
         NetworkView view = NetworkView.Find(id);
 
         view.GetComponent<Player>().characterName = myPlayerdata[0];
         networkView.RPC("AdjustPlayerName", RPC$$anonymous$$ode.AllBuffered);
         networkView.RPC("SetNameAbove", RPC$$anonymous$$ode.AllBuffered);
         view.GetComponent<Player>().level = int.Parse(myPlayerdata[1]);
         view.GetComponent<Player>().raceID = byte.Parse(myPlayerdata[2]);
 ...
         dataSet = true;
     }

There is every player recieve his own data including name. I want every player to show his own nickname in his child GameObject in his GUIText over network yet no one sees other's names or everyone sees $$anonymous$$Y name above all players.

avatar image Masterben135 · May 28, 2015 at 02:15 PM 0
Share

Where does myPlayerData come from? The problem might be in line 15

 view.GetComponent<Player>().characterName = myPlayerdata[0];

It's possible that each client is trying to set its own name to everyone else's character.

avatar image epicVoodoo · May 28, 2015 at 02:35 PM 0
Share

no, i've tested this question and have found out that each client recieves his own data... it's 100%...

avatar image Masterben135 · May 28, 2015 at 02:50 PM 0
Share

Hmm... Why do you call an "AdjustPlayerName" and "SetNameAbove" RPC within your AdjustPlayerDataOnEnterWorld RPC? Once you've gotten the player's name correctly for every player, it seems like it'd be a simple matter of creating a gui child over the player with the name inserted in. No need for more RPCs?

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by J.Mad · May 29, 2015 at 08:01 AM

You need a canvas. A player should have a small child canvas set as World Space. Canvas should have an child object with Text. Canvas should have some script that will be facing the canvas to the camera. That is a "modern GUI" approach.

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

A name For the Character Please Help 3 Answers

Problem with identifying players in network 1 Answer

How to use an RPC to send an animation over the network? 2 Answers

Photon Networking: RPC call doesn't work over other clients 0 Answers

RPCMode.AllBuffered Basic Question 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