Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
  • Help Room /
avatar image
0
Question by camfred · Jan 31, 2017 at 12:57 AM · networkingnetworkplayer

Trouble Getting NetworkLobby to update player names on Client

I'm using the NetworkLobby from the asset store. I'm attempting to take the form input (player name) and update the gameplayer using the associated lobbyplayer object. Per various tutorials and samples, the magic place for that to happen is apparently in the OnLobbyServerSceneLoadedForPlayer() method. I have the following code running on the Lobby Manager.

     public override void OnLobbyServerSceneLoadedForPlayer(NetworkManager manager, GameObject lobbyPlayer, GameObject gamePlayer) {
         LobbyPlayer lPlayer = lobbyPlayer.GetComponent<LobbyPlayer>();
         Player gPlayer = gamePlayer.GetComponent<Player>();
         gPlayer.playerName = lPlayer.playerName;
         }
     }

So far so good. The Player object has a synvar with a hook...

     [SyncVar(hook = "OnNameChanged")] public string playerName;

And the hook looks like this:

     void OnNameChanged(string value) {
         
         playerName = value;
         gameObject.name = "Player (" + playerName + ")";
         if (GetComponentInChildren<Text>(true) != null) {
             GetComponentInChildren<Text>(true).text = playerName;
         }
     }

When I run this, from the server's perspective, everything goes as it should. All the players get named correctly and their Text object gets set. From the client's perspective, player name never gets set for any player. What am I missing?

Any help would be very much appreciated, I've been struggling with this for a while.

Comment
Add comment · Show 3
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 Mike-Geig ♦♦ · Jan 31, 2017 at 04:04 PM 0
Share

Can you run the build as the server and then run the editor as a client and use the inspector to deter$$anonymous$$e if the value is being set at all? Perhaps it just cannot find the text component to visually update it but the variable is still receiving its value. Otherwise, you may need to use break points to follow the full flow of logic from the lobby hook to the name change hook

avatar image camfred Mike-Geig ♦♦ · Feb 02, 2017 at 04:00 PM 0
Share

Value not getting set at all by client. The more i test this, the more erratic it appears to be. I believe it has something to do with my player object prefab taking a bit to load (using uma). What's odd about it is the player lobby seems willing to move on to the scene with the client player object not fully loaded.

avatar image Mike-Geig ♦♦ camfred · Feb 02, 2017 at 04:03 PM 0
Share

What's uma? Also, delayed loading shouldn't matter. SyncVars are updated as soon as the object manages to load in. Can you submit a stripped down version of your project (just the bits that you can share / show the error) as a bug and send me the case number?

0 Replies

· Add your reply
  • Sort: 

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

114 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 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 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 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 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

Best Practice for an object that is both online and offline using uNET 0 Answers

Network Player Direction in Unity 0 Answers

How can I send update to all clients from one client in Multiplayer game in Unity3d? 0 Answers

How can I continuously receive the location of game object from 000webhost database? 0 Answers

[UNET] Cant get player to parent with boat and sync position 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