I’ve got a multiplayer game working with uLink (similar to built in Unity Networking), where my Server instance runs Unity in “headless” (-batchmode) without graphics on a windows server. Server gets RPC or state sync from clients and sends RPC or state sync to clients.
I’m looking into alternatives and trying to understand Photon.
With Photon, I can’t seem to understand what the Photon Server actually is or where I would script its behavior. Is it nothing more than a socket pass through for the clients?
In other words, with Photon, from what I’ve read so far, one client is always the Master Client, which to me is sort of like saying they are the Server (but from a networking perspective we are actually connected to a Photon Server not on a client).
Anyway, please help me get my head around Photon. I just can’t figure out what their server is except for a pass through for messages to clients. This is different than uLink for example where I can script what happens when the server gets an RPC or state sync and have that execute on the Server instance itself.
That’s not quite true, you can also use it to write your server logic in C# that runs on the photon server (assuming you are hosting it and not using their cloud service), this easily lets you run certain things on the server i.e. inventory, player stats, etc but it doesn’t run inside Unity therefore physics simulation isn’t possible.
You could just let all the clients sort out their own physics, or have a master client act as host for the physics but this obviously leaves your game open to abuse from people hacking their client. If that’s a problem then with Photon you can either integrate your own physics system into (a lot of development work) or you could also run headless versions of Unity that act as the master client for you – I don’t believe that Photon has anything out of the box to do this for you although someone with more Photon knowledge than me is probably better placed to confirm that.
Why are you looking to swap from uLink, depending on what type of game you are creating it might be your easiest option.
Well, Photon’s core is something based on ENet and can send UDP and TCP packages and the server framework is a C# application which allows you to write logic in it but unlike uLink there is no direct database or unity instance support on the server.
If you need to run unity on the server then uLink is the best option. You can run some unity instances as master clients on your private server network and make them authoritative but then why don’t you use uLink and use photon?
the game family guy online used photon and created many features which most of them are available in unitypark suite (uLink). At the time of that creation uLink wasn’t available but now it is
A video of that game’s creation process is available in videos section if you search for photon there.
Basically if you need something more ready to use and require unity on the server you should stick to unityPark suite or Unity’s built-in network or use Raknet’s latest version using the swag wrapper which is not usable in web players however.
uLink is really the best option in these situations.
The biggest difference to Unity’s networking is that Photon uses a dedicated server. This is not running in Unity and none of the players will host the game randomly. You also don’t have to run Unity in batchmode as server. This has pros and cons (as always).
For example, as Photon is not running in Unity, it doesn’t load scenes and doesn’t run the same physics engine. On the other hand, the full scene data is rarely used on the server side (to reduce complexity) and if you have a low-poly export of the scene, you could probably export to another format as well. It’s up to the game’s needs if you integrate a full blown physics engine or just use a collision detection library that also works on the clients. Or none of that.
For Family Guy Online, we optimized the world-simulating Unity instances for 1000 users and had 4 of them connected to one Photon instance. In that case, account logic and several other tasks were done by Photon instead of Unity instances.
Photon comes with a basic feature-set that can be extended but doesn’t have to. A lot of games work very well with just matchmaking and sending your custom data to players in a room. If you are missing accounts, inventories or whatever, you can easily add them to Photon. In best case, you pick a well known service you like and go ahead.
The rationale is that Exit Games can’t do everything at the same time. Instead, Photon focuses on the networking and makes it easy to integrate other services. Instead of learning how to use “Exit Games DB” or “Exit Games Accounts”, you use Facebook or any service you like best. It’s a middleware that plays nicely with other middleware.
Zinger: You have read about the MasterClient. This is part of the Photon Unity Networking framework (PUN), which in turn aims to be most compatible with Unity’s built in networking. Almost all concepts carry over from there and so we needed something that resembles a “host” or “server instance”. This is the MasterClient.
PUN does not have true server logic. We just send RPCs, updates and anything else through a Photon “room”. It still has some benefits over using a (random) client as server. Here is a comparison.
@tobiass
Logical man! So the short answer is maybe this. Photon is a networking/message sending middlewa but UnityPark/uLink as people call it is a Multiplayer/MMO middleware like Big world and hero engine but just instead of creating it’s own client uses unity as client which has pros and cons but because we are not comparing unityPark and BW/HE it’s out of topic.
Thanks for the info on family guy online. Do you mean making simpler codes and colliders for the server and removing things like meshes and animations and other stuff which aren’t required there?
Ashkan_gc: I don’t see how you can make that claim from what tobiass wrote, Photon IIRC is very well capable of driving large massive games (as has been proven several times).
I did not say that networking library is not scalable or is not good. It’s based on a proven tech called enet and is highly scalable with clients for too many platforms.
The server side logic of the game can be anything like many other networking middlewares like netdog and others and yes good games are using it.
If you have a scriptable text editor it’s not a word processor but it’s a really powerful thing, it’s not worse or better it’s just being a different thing.
From what he wrote i got this.
We are handling the networking side and are handing it good and it’s possible to add up anything you want from unity based servers like the family guy online to nothing or something in between like math.net library or …
so they are a networking library or message passing layer middleware if you want to call it that way.
There are things which can be improved on their tech like serialization and general architecture of the product (to have RPCs instead of opCodes and events) and better docs maybe.
On the other hand uLink is handling it in a much different way (i don’t mean the company name ).
Their way is proven as well. patrick wyatt called raknet a good library for game programming and their approach is much closer to raknet if you compare them. using RPCs and state synching is the standard in most networking and MMO midlewares if you want to compare in architecture level and they are solving a much bigger set of problems. Yes it’s possible to add all of these things in photon but it’s like saying why don’t you use C++ and write your engine while unity exists however the comparison is not fully correct because in the most low level part uLInk has clear advantages in architecture (custom serialization, RPCs and state synchs)
The only drawback is that you have to run unity on the server always but it’s being solved greatly as well and those games which don’t require it will not have to use it and others will benifit as well. They talked briefly on something in their forums called uServer which is a lightweight server instead of unity instances.
P.S huge games like shadowgun death zone is using their tech and their man vs machine was a finalist in unite awards so it’s not like that all good things are happening using photon. I think it was all about timing and the fact that photon much popularized by Unity technologies and in forums.
Photon Unity Networking is available for more than a year by now and replicates most features of Unity’s networking. You will find RPCs, state sync and more in it. It basically wraps the lower level api of Photon and uses it in one possible way.
I doubt Photon can be classified as just a network library. It’s covering that aspect but also implements events, operations (server rpcs), takes care of rooms, caching of events, matchmaking, load balancing and more. Features that are a common requirement for simple games.
However, we know first hand that one solution won’t fit all. More complex games always require custom features at some point, no matter how complete (and complex) the used framework is. As example, think about databases: There is not just one but many and even more apis to use them.
That’s the reason why Photon keeps away from implementing anything that’s basically another middleware. As said, this can be good or not.
Yes you are right , you have those features in lobby application as well.
PUN is a little problematic and incomplete because all RPCs are reliable and all features are not fully replicated.
On the middleware side and inclusion/exclusion of other features, i think more argument is out of topic. And i think you agree
It’s software and there is no silver bullet, allways there are pros and cons to everything.