MMO in Unity - Node.js VS. Photon

General Discussion on the Unity Engine.
Post Reply
uh oh
Posts: 17
Joined: Sun Jul 27, 2014 7:28 pm

MMO in Unity - Node.js VS. Photon

Post by uh oh »

Hi,

I was wondering if anyone here has any experience or knowledge regarding using Unity either with node.js or Photon for MMO purposes. And if could help to summarize the pros and cons of each solution in this thread.
All i think i know is that node should be slower using TCP and i'll have to use database like mongoDB with it. I know pretty much nothing about Photon, except i think i would be dependent on their services if i chose to go with photon server.
User avatar
a_bertrand
Posts: 1537
Joined: Mon Feb 25, 2013 1:46 pm

Re: MMO in Unity - Node.js VS. Photon

Post by a_bertrand »

You can as well work with MySQL with Node.JS, personally I would try to run the server with .NET but as said that's a personal opinion.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: MMO in Unity - Node.js VS. Photon

Post by hallsofvallhalla »

Photon works well and is fast but at the same time like you said you are reliant on their services and it can get pricey. Nodejs is very fast and can hold a lot concurrent users for a low price but as you also said you would need MongoDb which is also very fast. You can use MySQL with Node but I have yet to find a good library.

A custom .net backend would be sweet but may take some work. A lot of options. Just go with the one you are comfortable the most with.
uh oh
Posts: 17
Joined: Sun Jul 27, 2014 7:28 pm

Re: MMO in Unity - Node.js VS. Photon

Post by uh oh »

Thanks for your replies!
I’ve been looking into Photon a bit but all I’ve seen yet dealt with front end scripting without the need of server programing, meaning silly type of games like lets meet in a lobby, shoot at each other, then bye bye, log off, let bygones be bygones. What I have in mind is the main game design logic is on the server and what happens in the world is remembered by the server. So I still don’t know how back end in Photon is programed nor what kind of database does it use. But what I came across on their site is this link http://www.gamedev.net/blog/355/entry-2 ... ng-an-mmo/ to a devastating article :shock: and while my ambitions don’t even begin to approach anything resembling a AAA MMORPG, if only programing the multiplayer part would take the means and skill that only huge company can effort then I can just forget it.

I don’t want to create a twitch type of game, all movement and interaction would happen via mouse clicking and fighting would be turn based. I thought to make a very rough basic almost retarded version of the game that would convey the essential gameplay logic and atmosphere, could deal with a dozen players and some NPCs without major bugs and then try to get some reliable people to work with me.
What do you guys think am I completely mental or does it sound like something that could be accomplished?
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: MMO in Unity - Node.js VS. Photon

Post by hallsofvallhalla »

Don't listen to all the posts about why MMOs are so hard and why you shouldn't make one. Most of them are written by people who failed at making one. You can build anything you want . The only way you fail is if you give up before you start.
User avatar
a_bertrand
Posts: 1537
Joined: Mon Feb 25, 2013 1:46 pm

Re: MMO in Unity - Node.js VS. Photon

Post by a_bertrand »

Be careful with having all the logic on the backend. Of course it would allows a lot more security against exploits, BUT the cost of having all that running on your server means your server will work a lot and will be the bottleneck of your game. If you have 2 players that will never be a problem but as soon as the number of players grows the needs on your server side will grow as well, and unless you are with unlimited funds I hardly see how you will be able to pay the bills for your servers.

Personally I design my own games / engine in the reverse approach, where the logic is nearly all on the client side, sure people could hack the client and then gain basically anything they want, but at least I don't have to pay huge bills for my servers, specially for games where players hardly pay anything,
Creator of Dot World Maker
Mad programmer and annoying composer
KHill
Posts: 19
Joined: Fri Jun 03, 2016 1:02 am

Re: MMO in Unity - Node.js VS. Photon

Post by KHill »

This is an interesting discussion, and is where a programming style called MVC comes in handy.

MVC stands for Model, View, Controller.
Model: This refers to the database backend, and there is typically nothing more than basic calls to said database.
View: The view is specifically what the user views when they load any given page. View is used to make it look pretty, so this is where you would do front-facing UI (redundant)
Controller: A controller is the service layer that sits between the model and the views. The basic functions of a controller is to take the data retrieved from the model and translate that into the actual functions/calls that will be made to display (or take in) data in the views.

This is a bit of an oversimplification, but TLDR:
It makes sense to have the logic lean towards the backend, and MVC provides a nice model through which you can achieve that with a nice balance between front /back end.

Anyways, those are just my musings, I'd they helped great, if not, hopefully someone learned something new :)
User avatar
a_bertrand
Posts: 1537
Joined: Mon Feb 25, 2013 1:46 pm

Re: MMO in Unity - Node.js VS. Photon

Post by a_bertrand »

Indeed MVC do split the responsibilities, but nothing said where each pieces should be. You could very well have the controller on both side (client and server) or just on one side. Here my previous point was to warn "uh oh" that if he place too much logic on his server side he will need soon a data center to handle his MMO. While if he unload the logic on the client side, he may risks that some nasty players exploits it and jump on top of whatever top list, or create loads of virtual money out of the thin air.

For example, Second Life had a very strong issue with the number of concurrent players in a given area, and therefore limit the number of players which could enter the area. Why? because an area was backed by a single server, and as a lot of logic was running on the server side, only so many players could use the same server at a given time.

This issue of splitting the logic is actually something I never really saw a good answer to. Ideally your servers should only keep the persistent data and everything else should work like a p2p, and therefore have a small server and offload the work to your customers. You could have code within the client which checks the behavior of other players, and then report it to the main server, but that could be abused as well. Overall it's really a complex problem.
Creator of Dot World Maker
Mad programmer and annoying composer
User avatar
hallsofvallhalla
Site Admin
Posts: 12031
Joined: Wed Apr 22, 2009 11:29 pm

Re: MMO in Unity - Node.js VS. Photon

Post by hallsofvallhalla »

In the end you only have two places to place the logic. Client or server. Regardless of how you code it one of those two will need to do the work. It costs more work but there are several ways to do all the logic on the client and still keep the cheaters away. The truth of it is it is highly doubtful any indie making an MMO will ever truly be MMO. Getting a few thousands sign ups is pretty tough and getting a few thousand concurrent players is even tougher.
User avatar
a_bertrand
Posts: 1537
Joined: Mon Feb 25, 2013 1:46 pm

Re: MMO in Unity - Node.js VS. Photon

Post by a_bertrand »

Well, NEaB had lot more than thousands register, and at peaks it had more than 300 concurrent players. Already at that point PHP was somewhat of a pain, and since then I moved away from server side logic for my own stuff.
Creator of Dot World Maker
Mad programmer and annoying composer
Post Reply

Return to “General Unity”