Hello folks! I’m getting used to Unity as I’ve decided to start moving my Actionscript 3 MMO over to it, since it seems to have a more promising future. I’m liking it so far! One of my current issues however, is that I would really like to use the built in Unity physics instead of my own. Reason being, the Unity physics system I’m sure functions a little better and has a lot more advanced features. The issue is that this is an MMO, and the server needs to run its own “version” of the game so that it can keep track of things like enemy positions, player positions, and really any major physics related positioning. My server also runs C#, which is handy.
A key part of this is that the server and client need to be running the exact same physics calculations, or else it’s significantly easier for things to get out of sync. So in essence, I’d need a copy of the Unity source code for the physics engine, (hopefully one that is easy to understand and port to my server). Does this exist somewhere, or has anyone else had experience having to cover this issue? Unfortunately it’s looking like I’m going to have to stick to my own custom physics engine, but I thought I’d ask since I’m still new to Unity and wanted to double check that there wasn’t a solution to this.
Unity uses PhysX internally, whose source code is available here.
However, it’s C++ and I’m not sure if/how you could build a server resulting in the exact physics calculations as in Unity. I really recommend you searching more information on Unity and authoritative servers to find out how others have resolved this situation. I’m not expert in networking, but I’m pretty sure it’s a common scenario with many practical solutions available.
Ah ok, thanks for the info about PhysX! So it’s definitely an even more advanced physics engine that I’d already thought. Looking briefly at it, I wouldn’t even want to think about trying to understand and port all of that code. >.<
You’re right, I’ll have to think about another solution if I want to use Unity physics. Perhaps I can have one of the clients act as the “authority” telling the server where enemies and such are. This will of course enable the game to be more open to hacking, and add a little more latency into the equation, but I could probably work around those. I’ll try to read up on possible solutions. In the meantime, if anyone has any other solutions please let me know!
You may run a special instance of the application in headless mode in your server, so it would act as authoritative server. The headless mode is triggered by the command-line option “-batchmode”:
The Multiplayer and Networking section is a must-read for understanding all the tools and techniques you can use in your game:
Thanks for the info! I did read about the “headless mode”, however I also think that wouldn’t work due to the restriction on my server for running certain code. It’s hosted by Player.IO and they have restrictions against certain code running due to security reasons.
I’ll give the links you posted a check. It’s mostly the general approach that I was curious about. I wonder how other MMOs do it, if they all run a simulation on the server, or if they are mostly client side with physics.