TGR Pong with Mirror Networking Update!

A quick update on The Game Realm Pong with Unity and Mirror Networking.

Well its been more than a few weeks, but I finally got some real progress done with my pong game using Mirror Networking. I finished the Tic Tac Toe game using Mirror and used that as a base. There were still quite a few changes I had to make in order for the game to be more efficient, like combining everything into a NetPlayer game object. Creating the Ball game object, tweaking the UI.

TGR Pong in Unity

There were quite a few hurdles that I had to go to Mirror Networking for help with on Discord. Mainly just to understand the API. Things like passing messages between clients, client authority, syncing movement between clients, instantiating network objects, etc.

TGR Relay Server In Unity

The main issue I was having was running everything through a relay server. I guess its not very common or people just aren’t sharing their wisdom. The reason for the relay server is to get away from router blocking with player 2 player connections and alleviate the Android/ Iphone hosting games issues. Of course using a relay server will increase the latency and eventually we will see how the pong game does when I run the clients through the relay server app on a VPS server.

So here is a video of the exciting game in action. It shows how well the objects are sync’d across both clients. This is where I failed when using LiteNetLib Networking. I wasn’t able to write a good algorithm that kept the objects sync’d like this. Thats when I knew I need to go to Mirror, they gave a pong example!

As of right now, the TGR Pong game is playable with 2 clients and keeps score. So all I have left is to enable player statistics, logging in, and make sure singleplayer is still working.

I will hopefully get this completed this Memorial Weekend! Speaking of, thank you to all the service men and woman and your families for the sacrifices and things you do for us! We love you guys and gals!!!!!

Memorial Day Thank You

Networking Rework Again!

Mirror Networking

Well, here I go again.
I finished moving my multiplayer TicTacToe to the new networking system using litenetlib and it worked beautifully! I had to do a complete rewrite on the relay server also. In the end, everything worked great and the world was happy!

I then excitedly decided to work on the multiplayer pong game. The whole reason for the TicTacToe game was that it is one of the easiest games to write, its turn based and perfect to use for my first multiplayer game. So when I finished that, I figured I need to work on something that had some live action, synchronized objects, player movement, etc. Thats where pong was a perfect choice.

I got all the way to the end where I was trying to sync the player paddles and the ball. I spent a few weeks trying different things but ultimately in the end, I decided to look at other Networking solutions, preferably something that already had syncing of variables under the hood. With LiteNetLib, you have to write your own syncing algorythms, and that is definitely not something I could pull off. I got pretty close a few times, but something would always cause it to get out of control.

Photon Pun2
The first thing I took a look at was PUN2, or Photon for Unity Networking, version 2. Due to the type of architecture I wanted, I needed to create a seperate server that manages the clients, not so much the game, but the clients themselves, somewhat of a matchmaker with more control. Photon Server seemed to fit the bill perfectly, at first anyways. After diving into it, I came to realize real quick the lack of documentation. Without this, its damn near an impossible task. Getting PUN2 working with the server was pretty easy, but in order to get the server to do what I wanted, was requiring too much research, forum posting and begging for information. I finally decided to go with Mirror.

The downside of Mirror is pretty close to the same as Photon, lack of documentation. Very abstract or high level examples that are tough to understand and not too much information available, at least for what I was looking for. I finally decided to sponsor it and get access to premium help, this was well worth it. In the end, after a few weeks, I got going in a good direction and should hopefully be able to get the Multiplayer TicTacToe rewritten using Mirror soon. A few good things about Mirror is that it was based on the original Unity Multiplayer UNET, its open source for those that get off on that sort of thing, tons of examples (If you can understand them, not for the basic type like me) and once you get a grasp of it, it gets easier to understand and implement.

I just wanted to give a quick update, document my progress and take a break from spewing code, lol.

Ok, back to it! See ya on the next one!