• 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 /
This question was closed Jan 08, 2021 at 06:35 AM by JohnSmillie for the following reason:

Figured out the problem

avatar image
0
Question by JohnSmillie · Jan 07, 2021 at 07:51 AM · multiplayer-networkingloginmirrormmo

Mirror: Linking Login Info with the player

I have a multiplayer mmo-like game project using Mirror with an account log-in system. The first scene is the Login menu and upon a successful login it switches to a scene with all the networking stuff, allowing you to host or connect to a client. Upon connection, I'd like to be able to link the name of the player with the username used in the login from the menu.

I can't seem to figure out how to do t$$anonymous$$s using Mirror's Network Manager and Network Player relations$$anonymous$$p. The best idea I could come up with is have a gameobject with DoNotDestroyOnLoad that logs the username as a variable and carries it over to the scene, where the player looks for the gameobject and sets that name as its own. However, t$$anonymous$$s has it working for the first player, the host, but every subsequent player that connects gets the same name as the first. I guess I thought the player would take the name from the current game, the same one where they log in, but it seems like the only gameobject that can be accessed is the one holding the name of the player that's hosting, w$$anonymous$$ch is in the same game as the host network manager. How would I make it so that each player has their own respective name?

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

1 Reply

  • Sort: 
avatar image
0

Answer by ddooms · Jan 07, 2021 at 08:51 AM

The problem with t$$anonymous$$s is that the master is the one that "owns" the object. What you need to do is instantiate an object for the player and set that objects owners$$anonymous$$p. However I feel t$$anonymous$$s is a bad implementation. What you should do instead is instantiate s class that holds information about the player that doesn't compromise their account, like usernames. Instantiate the class, set it's information to reflect the player, and then set the owners$$anonymous$$p to that player (t$$anonymous$$s usually happens automatically in photon, unsure about what you're using). Then I would check all instances of the class to see if it belongs to the player (isMine in photon) and grab the correct one to get their information.

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

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

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

Related Questions

mmo/server question.. 2 Answers

Multiplayer Game Highlight Material 0 Answers

Server game object not syncing position after if statement 0 Answers

Multiplayer Network for Battle Royale 2 Answers

I have a script that work fine with mirror but visual studios is reporting false negatives 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