.:: Alex Erne :: PHP/MySQL & Unity3D/C# projects ::.
Recent news
Like me on Facebook
* advertisement *
  22 May 2016 - Experimenting with clients & server :: Posted in Unity3D

The last couple of years (ever since I started to play Lineage II back in 2005 actually) it's been a dream of me to make a small-scale MMORPG, but I had no idea on where to start back in the days. That was before I discovered the Unity3D engine. Now that I've gotten used to the Unity3D engine, mastered C# and OOP to some degree it's time to start on that dream...

To get started on the dream, I've made a small client-server script earlier this month and I was able to establish a connection. Sadly though I was not able to send data between the client and server. Digging a bit deeper into the Unity documentation, I discovered that I was using the legacy instruction set that's no longer supported since version 5.1 (Unity is now beta-testing version 5.4).

So I had to dig some deeper into the multi-player components Unity3D supports and it seems that it's actually quite easy in the basics to setup a multi-player game with the new instructions. The guys at Unity have made a very well designed High Level API that takes care of everything you need. It allows regular player-side hosting and matchmaking of games (shooters come to mind) and I  guess that's the main reason for what it's been designed. But with a creative mind you can adept the player-hosting of games into a dedicated server that allows multiple clients to logon. And that's where the MMORPG idea starts to take it's form...

 photo Screenshot 2016-05-18 11.15.35_zps6rfwwnnn.png

In the above screenshot I've been playing a bit with the basic tutorial code and experimented with multiple connections on one PC and as you can see it works pretty nicely. There is one dedicated 'server' there (3rd from the right on the top row) and I have 26 clients connected to it. The communication between the clients and the 'server' goes pretty smooth (duhuh - it's all on one PC ) in performance it's not overly heavy on my old AMD Phemon II 1090T with 16Gb. That would imply that my Linux machine (AMD Phenom II 945 with 8Gb) should be able to host a dedicated server easily...

 photo Capture 20160522 0740_zps4walir97.png

The only problem remaining though is that every screen (inluding the 'server') is showing the same cubes. And while cubes don't take that much performance, imagine a server with 100s of players online having to cope with the full map and each and every textured player. That's mean that my Linux machine won't be able to keep up with performance, and therefor I made an other test.
In the above picture I've changed the 'player' in the Unity editor from a cube to a capsule to see how it'd behave on the server and other client. As you can see, only the Unity editor has it's apperance chanced and it stays a cube on the server and other client. And that's exactly what I wanted to make sure: the apperance is client side only and not broadcasted to the other clients.

With this knowledge I can make players, the game world and monsters/NPCs appear as they should be on the client, while on the server they will consist of only simple things like capsules and untextured structures that all have a collision box. This way I can keep the server running at maximum performance AND keep collision (and other checks) on the server side of the game to avoid cheating.

Of course, this is only the groundworks of my MMORPG. I still have a lot to learn when it comes to modelling and animating 3D objects and figure out how to use a database with Unity3D on the server side. And speaking of groundworks, remember the d20 project I've been busy on the last few months? It's still alive and I'll be using it (in a modified form) for my MMORPG...

Post A Comment!
* advertisement *
* advertisement *

This website is Copyright © 2009 - 2016 Alex Erné
PHP/MySQL coding by Alex Erné Copyright © 2009 - 2016 Alex Erné
...all rights reserved...

AE games™ and the AE games logo are Trademarks owned by Alex Erné
TetraGems™, Burst-a-Bubble™ and the Burst-a-Bubble logo are Trademarks owned by Alex Erné