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 /
This question was closed Oct 11, 2012 at 09:11 PM by KiraSensei for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by KiraSensei · Oct 02, 2012 at 06:21 PM · networkdata

How to pass data threw server ?

Hello everyone !

Here is my scenario : Some players want to play my multiplayer game (yeah !). When a player creates a server, he chooses a nickname. When the others want to join the opened game, they choose a nickname too. How can I be sure of the unicity of the nicknames ?

In my opinion, HostData.comment could be an option. Like, when a player has chosen a name, I put it in the comment of the hostdata, when an other one wants to join, I check the comment and if it contains the nickname, I stop the second player and tell him to choose an other one. The trick would be to concatenate all the nicknames in the comment and separate them with a special key (to encode and decode it easily) which could not be in a nickname.

So here are my questions :

first : is my idea would be an option ?

second : is there an other and easier method to do what I want ?

Thanks !

EDIT : up .

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
Best Answer

Answer by MibZ · Oct 03, 2012 at 09:28 PM

I imagine since you have a multiplayer game that you have some kind of List filled with all players - in my mind it would be simpler to have a for loop that iterates through your list comparing the new nickname with existing ones. I'm not sure which method is more efficient, but both are definitely possible.

I feel like I'm not answering your question fully though, your title and body are asking different things.

Comment
Add comment · Show 6 · 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 KiraSensei · Oct 04, 2012 at 06:13 AM 0
Share

You may be right, I badly explained myself... I don't have a playername list because I don't know where I can stock it since I change of scene. I supposed I could save it in the HostData.comment variable, but I'm looking for an easier way to do it.

avatar image MibZ · Oct 04, 2012 at 03:12 PM 0
Share

The best way to preserve data between scene loads is to make an empty GameObject and attach a script to it that you store whatever data you want to keep between scene loads inside of.

In the Start function of the script add the line: DontDestroyOnLoad(gameObject); When you change scenes any object that line gets applied to will be maintained, but if you load the scene that it is placed in more than once you will end up with duplicates of the object, so my solution to that is that the first scene loaded plays a splash screen animation and creates the empty with DontDestroy, and after that the splash screen scene is never reloaded.

avatar image KiraSensei · Oct 04, 2012 at 03:50 PM 0
Share

Ahhhh of course ! But in my example, this will be the player server who will be the first one in my "waiting scene", just after creating the game. $$anonymous$$y players client will be in it only after choosing their nickname.

So this means that they must connect to the game, check if the nickname is not already taken without being in the "waiting scene". If it is the case, they are disconnected of the game. Is it ?

avatar image MibZ · Oct 04, 2012 at 05:16 PM 0
Share

Hm. I'm not the best person to ask about networking code, but I would imagine that when someone tries to connect to the server you could send a message from the client to the server with their chosen nickname, check if it is available on the server side when it receives the message, and if it is send a message back to the client telling them to start connecting/telling them to choose a different nickname.

EDIT: Typo

avatar image KiraSensei · Oct 04, 2012 at 05:20 PM 0
Share

Yes, but from what I know it is not possible to talk with the server if you are not connected to it ?

Show more comments

Follow this Question

Answers Answers and Comments

10 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

Related Questions

I'm making a multiplayer game but .. 0 Answers

Run PHP query On Players Disconnecting from game (Coroutine) 0 Answers

Send data through network between different objects/scenes 1 Answer

How I can convert data to Wifi/ Multiplayer/ Network 0 Answers

How to receive streaming data over a UDP connection? 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