I wanted to do a simple solution to just put a component on a object that would sync the position of a game object to all connected clients. TurNet which I call my network library was made because I want a simple and easy way to make multiplayer in C++ without writing all the low-level networking yourself and just focus on the top-level.

My First obstacle was that I was getting errors when including the TurNet library problem was that the library included winsock when my main program also included in another library and I had conflict errors. When I got that sorted I started to progress. Sometime earlier I made a simple demo with my Library in our game project engine I made so that you can see the currently active users in a scene and display a debug cube at the position they are in the scene. I made it for fun but it relevant since I also added that to my own game engine called GamerEngine I have been working on. In the showcase here you see me and Erik Ljungman testing out my first version of my network library

I made so that when you want so check that a specific code snippit wanna run on the client only or just the server you can check that inside the code you write. This code is from when a object move it should move randomly inside a said area and with this the client will never run this code and when the server updates the object I doesn’t return and continues to run the since a server is not a client on the server.

Another problem was I dont wanna include mess so what I did was when you wanna add a message to the server to be sent out to the clients connected you just have to include one file that holds everything that you need to send messages to clients. When you push a message it gets added to the list and when the server have done a whole loop through the code it will check if there is any new messages to be send and if there is any they will send it out to the clients.

Final product is show here when I put on the components on a new game object and save the scene when I reload the scene on the server everything is now synced and if the server updates game objects that is supposed to sync they will do it. In this example I have a component that runs just on the server that just randomly gives the object a position and then the server knows that the position is “dirty” and is no longer the same. And therefore sends out a message to all clients connected to the server with the new position and every movement is smoothly lerped on the client side.