I’ve been searching around for a tutorial or example on how to create an online game made in Unity, but communicates with a server not made in Unity. (be it made in Java, C++, plain C#, etc) I’ve read that this is possible, but I can’t seem to find any information on just how this is accomplished. It leaves many questions: What is the byte ordering of the packets? How are the packets structured? How do I determine the packets sent via calls to Network.Instantiate and what not?
The type of game I’m creating is suitable for players to run the server program themselves (ie. Minecraft, Terraria, Starbound, etc) and I personally detest cloud based storage/hosting no matter how good people flaunt them to be. The way I see it, I want the online playability of my games to be at the player’s discretion whether or not they want to host it themselves or have it hosted. It gives them control over what they paid for, and it allows them to preserve the game if/when I choose to discontinue it.
Well yes its very simple you can make everything yourself or you can use a framework like lidgren. There are also Tutorials how you create a Game Server.
Could you point me in the direction of these tutorials, please?
http://genericgamedev.com/tutorials/lidgren-network-an-introduction-to-networking-in-csharp-games/
Here is a good tutorial for Lidgren.Networking. Well I create Packets for the communication between client and server in wich i write/read the data in the Lidgren msg. Then I have a packethandler on each site which delegates the package to listeners that have registered on the packet type.
1 Like
Oooh I see! It’s just like an ordinary C# program.
mabenan, do you have a demo/sample of just a single scene in unity with the lidgren library setup ? im now looking at this library wondering how to get started with it too…i just need something simple to look at to figure out how it works, like a client and server and just moving a ball or a cube around on both would be great.
I was on this same journey myself pretty hard. If you want to get running with the groundwork laid for you then a solution on top of something like lidgren or raknet would be good. Or you could roll your own and start from the first socket. I went the roll your own route simply just cause I really wanted to learn the lowest possible level of networking I could out of curiosity. If you decided you wanted to do something like that then studying socket programming in general will get you started. It’s simple in principle looking back but when I first started sending position updates from network dll’s I made and put into unity to my own socket server and sending out to other connected clients, triggering network events, etc, it felt pretty cool. Either way you have a bit of work ahead of you for learning if your starting from little network knowledge but don’t let that stop you
I suppose I could use a threaded TcpClient/Listener
I’ve already thought about it to publish my library but i have no time to support it. So I can only give you the libary without a documentation and i don’t think that this would be very usefull.
I’m fine. I’ve developed servers and clients before. I just wanted to know if there were any obstacles Unity might hurdle my way in regards to communication.
No there are not the only thing you have to take care of are CallBacks to the main-thread from the Listener Thread.
1 Like
Im willing to take a chance and try and muddle threw your library … all im looking to do for starters is the basics…display a cube on the server side…and watch it move on the client side…I just don’t know how al of that hooks up into unity…but im willing to build off of any solution thats free and can support more then a couple hundred users.
Thank you Mabenan, im excited to try this out