Hey,
I’m doing a LAN multiplayer game. Before joining a session, every player must enter a name that will be used in the session.
Now I want to get these names in the actual game level. So my question is, how can I transfer the names variables from the Menu level to the Game level ?
I thought using a game instance …
I don’t know if it’s a good idea, and if it is how should I use it ?
Thanks by advance
If this is multiplayer other players will need to see your name, so in that case you’d send the name you selected to the server and the server can replicate it.
For your question, the game instance is fine, you can store the name in the menu level, and then in the game level you can retrieve it from the game instance.
Ok, thanks.
Please correct me if I’m wrong :
From the menu level, I would send my variable to an array of strings in the game instance which contains all the players names.
Then, I get the array elements in the game level from the game instance.
Is that right ? I don’t have access to my computer now but I want to make sure I understand everything
That’s correct.
Thanks for the infos
Wait
I also have been reading that there is one game instance per executable …
And I can’t send names to the server in the menu cause … There is no server at this moment, all players are still clients because they haven’t joined a session, right ?
Yes that’s what I referred to in my first answer, once you connect to the server you should send your name, and the server should update your name, or once you connect you send a request spawn event with your custom name and then the server spawns your character and sets your name.
I would do this in the player controller.
Thanks for your time, appreciate that