- Home /
(C#) Help with Multiplayer Features - Photon Unity Networking
I'm creating a sandbox building game in Unity. I have a basic understanding of Photon (PhotonViews, Joining/Creating a room, etc), but I need some help with a few things to make this game look and feel more professional.
I was hoping someone could clear up two things for me.
1: I'm very certain that this is possible, but I don't know how to do it...I need help setting up a master list of player names, sort of an account system, that allows players to enter a username when they open the game for the first time, and always associate that username with that IP, so that when they open the game again, it automatically sets their name to the first chosen name, and doesn't allow anyone else to be able to set that as their name.
I assume I could set up a list of names somewhere through the central server and have a little loop that runs through that when you try to create a name, and doesn't let u create one that has been taken. However, I have no knowledge of how to do this.
2: I know you can save files through code to the computer, but I don't know how. This is something I can easily Google and isn't the point of this question. My question is this: would it be possible to, when a player joins, Open a Photon Room named "their unique player name" that saves to their computer through a click of a button/every 10 minutes or something? When there are no players in a Photon Room, I know they close automatically. So when the person reopens the game, I want it to load an empty Photon Room and, in that room, spawn in the Scene that was saved last time they played, giving the illusion that the room is always open?
I don't know if that is possible, but it doesn't seem too far fetched - save their edits to a world while playing, then when they reopen the game, the saved scene is loaded in a new Photon Room.
-Thank you ahead of time, I really appreciate anyone who answers one or both of these, or even people who take the time to read it all.
Answers is probably not the best place to discuss things like this. There is not just one answer. Even less so, because you asked more than one question...
1: You need Custom Authentication with some "community" which lets your users register. At register, check the name for uniqueness. At connect, just make sure the client authenticates as some of the users you know. You can't use the IP address to identify a user, as that usually changes. Just test it yourself over several days on some page like whatismyip.com or so.
2: Look up User Prefs in Unity to store info locally. You can save the room-content locally or in some online service. When you enter a room, you can use that data to create the illusion of an ever-existing room. Saving custom levels is not built-in to Photon, so it's going to be extra work. However, there are already games that do this: Cube$$anonymous$$en, Fight the Dragon, etc.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Unity networking tutorial? 6 Answers
Collision over photon network is not working 1 Answer
How to implement server side logic with PHOTON? 0 Answers
Access host's object 0 Answers