I have a couple of questions on server side tech that can be used with Unity. I’m not a professsional programmer and so a lot of these questions will seem a but newbiw-ish so please bear with me.
Just to give you a little background. I’m now developing a demo for a 3rd person shooter which includes a single map and mulitplayer functionality (single player and team death match). Think Counter stike / Cross fire in terms of game mechanics. As I’m aiming to finish this demo by the end of the year there’s a few things I need to clear up in regards to the server side. I have a good idea of what the answers are though I’m not 100% sure.
I’ve now got mulitplayer functionality in my Unity built demo and I connect to the master server in order list my game so others can connect. Stupid question, but why do I need to have server side tech like Exit Games Photon or Smartfox Server if I already have a multiplayer session going just using Unity. Can I not just have a dedicated server version of my game running on a server somewhere with just Unity? I assume this is because I’ll need a database of users, my own master server etc? What exactly do we get from using Photon, Smartfox etc?
When teams are in production of multiplayer games do they usually test using a server that is located outside of their studio? Or one that is located in the studio. Obviously during beta phases it would be external, but how about during main production?
If I use Photon for example, as the server side tech. Would it mean that I’m connecting to a server owned by Exit Games, or is this simply the software which I would then upload to a server somewhere? Would that server need to support certain languages in order to run Photon?
When users connect and enter in their name, password etc. Does this connect to a user data server somewhere which is separate from the game servers? To hold all the user data such as XP, purchased items, friend etc, would we need to use some different tech outside of Photon? Or is this included in the server software packages?
When we’re testing the demo with a server located outside of our internal network, is it secure? What I mean is, is this a standard way to test an online 3rd person shooter game, and would we simply need to set up password / firewalls etc to ensure no-one hacks-in? Sorry for being vaige on this one.
How would I upload a version of our demo to the server? Is this done through FTP or through Photon for example? Do I need to have a server version of the game running on the server? Basically the same as the client but handling all the logic and updates between the clients.
Does photon / smartfox also include chat services and lobbys etc? Or is this something which is just done in Unity?
Does you know of any good sites / articles that can explain all this in newbie language.
Phew! I’ll leave it there as I know this is quite a big post. Again apologies for some of the questions as there probably really obvious, though I need to get clear on these points before moving ahead.
Let me see if I can answer some of your questions.
You can certainly use Unity’s built-in server solution to create multiplayer games without having to use a 3rd party technology. So why would you use 3rd party? The main reason is just focus. The Unity team is amazing and they are great at making 3D software. Their main focus is on that. When it comes to making a highly scalable feature rich multiplayer server, that is not their expertise. There are companies that specialize in that type of thing, like Electrotank (the company I work for). Electrotank makes ElectroServer. When you go with a 3rd party server solution like ElectroServer (or Photon, etc) you can trust in the support you get and quality of the product because that is the core of their business.
It is common during early development that the server is hosted on someone’s local machine. This helps with rapid development and testing. When the team is ready to have more than one developer working on the multiplayer aspect of the game, then the server needs to be hosted in a location that is accessible by all involved. This could still be on the local machine of the lead server developer - and that developer just makes it remotely accessible. If you are using a continuous integration system (like Bamboo from Jira Studio) then it is common to have the server auto-deployed on a remote testing area whenever someone checks in new code. That is something we do on projects that have many developers.
I’m not that familiar with Photon. But with ElectroServer, the server software can be installed anywhere. It is not hosted by Electrotank. You just download the software from Electrotank, and then install it on your own machine or some remote server. It is your choice where you want it hosted. You asked about the server supporting languages - no, the location of your install doesn’t have to support any special language. ElectroServer is written using Java, which means it will run anywhere.
Now you’re getting into the area of custom code. Typically all of your game clients connect and login to the game server. The game server usually has a lot of basic features built in, such as the login ability, and the ability to communicate with other clients, etc. But there is nothing built in for for XP, items, quests, etc. Most games implement those things differently so it is up to you to add those features (unless you are using a virtual world platform like EUP). So basically, you’ll need to supply your own database and write your own code to handle the game data.
Is it secure? Well the word security means a lot of things. If you are using ElectroServer for example, here is some basic security that will keep almost anyone out. a.) You would require a username and password to login. This is enough to keep almost anyone out. b) You can enable password hashing if you wanted, and that really makes things more secure. c.) If you so chose, you could just turn on security and all messages are encrypted. This isn’t recommended for game messages, but you could use it pre-game to do some extra handshaking.
You would upload your Unity client via FTP. Your server-side code (that runs on ElectroServer or Photon) would be uploaded via FTP if you wanted, or via any number of other ways.
I’m not sure about the details of Photon, but ElectroServer includes these things.
No problem about the big post. Multiplayer has kind of a big learning curve. I’m working on some tutorials that I’ll hopefully have done soon that I can post around here. I wish you luck!
SmartFoxServer has a remote admin tool, so if you install it on a server you can easily manage it.
SmartFox and Photon have demo projects for you to get started with Unity3D( dunno about Electroserver )
BeamServer2 is also another solution, it’s a socket server on which you need to build your application.
As for Unity’s built-in networking…i would only use it togheter with a master server. For anything else i personally like SmartFox more.
Adding to what appels just said. Yes, ElectroServer also has a remote admin used to manage the server (and to view real-time stats). And it comes with some Unity examples to show how to connect to the server, login, build a simple chat, and the basics of using UDP.
I hadn’t heard of BeamServer2. I’ll check that out.
Unity provides “client side prediction/dead reckoning” to handle latency. Jobemakar and appels: I couldn’t find any info that said that electroserver or smartfox provide this important service “out of the box”.
Correct, ElectroServer doesn’t provide any dead reckoning algorithms right out of the box. But you can certainly write them to work with it. And in this book:
you can find a pre-written prediction/dead reckoning algorithm with ElectroServer. It is in ActionScript, but the port would be easy. I’ve since written a better one that is really good and hope to port it to C# soon.
Anyway, take it for what its worth. The different servers all have their pros and cons.
Thanks for your replies to the post, very much appreciated Makes a lot more sense now. I’ll check out the links you posted Jobemaker, cheers.
Another quick question:
Do teams generally use MySql to build their user database? Or can this all be done using Unity / Electrotank / Photon etc? In code, would this be set up as somekind of class / struct? For example -
//psedocode
class UserData()
{
name
password
XP
}
//an array to hold all user data on the server
var userDataArray = new Array();
// when user signs up, add to the array. Or when logging in, look through the array.
Or am I way way off here
Assuming we use Electroserver for example on the server side, would that mean we would need to replace all Unity networking code with the Electroserver networking code? For example, at the moment I call:
Would this code need to be replaced?
Does the same go for the Networkview components in Unity?
And the networkRigidBody script (found in Unity M2H networking tutorial)?
Ok, one more super dumb question, bear with me When I play the demo at the moment, I start a sever on one PC, and connect clients on other PCs. The lag is sometimes quite obvious. I assume that this is because I’m connecting the machines through the internet and not an internal network, because it’s a home internet connection (not a ultra fast enterprise connection) and because usually clients connect to dedicated powerful server, not a PC (therefore the overall network processing power is slower). I believe these are main reasons for heavy lag, Is this correct?
Can Electroserver / Photon be used with Monodevelop? Or it must be Visual Studio? / Visual studio express?
Usually the server will support any database choice that you want. MySQL is a popular choice, so yes, many companies use that. As for the example code you wrote in there - I’m not a database guy so I don’t know how to work directly with one. However, your code looks to be more of an in-memory thing rather than a persistence thing. You’d want persist it to the database rather than just adding to an in-memory array. I’d consult a database guy.
Yes, you’d replace the network API with the ElectroServer API. Here is a basic video tutorial (part 1 of 3) that shows how to do that - connect login to ES from Unity. http://www.youtube.com/watch?v=5OA3tPruXT4
Yes, the lag is due to the Internet. There is nothing big you can do to really reduce the latency. But you can hide lag by writing code to smooth over it. And sometimes you can make smart game design decisions to help with lag.
I can’t speak for the others, but yes ElectroServer can be used with MonoDevelop and Visual Studio (or express).