Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Making a non-Unity made console-based server to communicate with a Unity 5 game client

Discussion in 'Multiplayer' started by SchalaZeal, May 4, 2015.

  1. SchalaZeal

    SchalaZeal

    Joined:
    May 4, 2015
    Posts:
    10
    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.
     
  2. Mabenan

    Mabenan

    Joined:
    Feb 7, 2014
    Posts:
    132
    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.
     
  3. SchalaZeal

    SchalaZeal

    Joined:
    May 4, 2015
    Posts:
    10
    Could you point me in the direction of these tutorials, please?
     
  4. Mabenan

    Mabenan

    Joined:
    Feb 7, 2014
    Posts:
    132
    SchalaZeal likes this.
  5. SchalaZeal

    SchalaZeal

    Joined:
    May 4, 2015
    Posts:
    10
    Oooh I see! It's just like an ordinary C# program.
     
  6. Mabenan

    Mabenan

    Joined:
    Feb 7, 2014
    Posts:
    132
    Jep
     
    SchalaZeal likes this.
  7. TeachableNoob

    TeachableNoob

    Joined:
    Apr 23, 2015
    Posts:
    21
    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.
     
  8. AlwaysBeCoding247

    AlwaysBeCoding247

    Joined:
    Jan 27, 2014
    Posts:
    41
    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
     
  9. SchalaZeal

    SchalaZeal

    Joined:
    May 4, 2015
    Posts:
    10
    I suppose I could use a threaded TcpClient/Listener
     
  10. Mabenan

    Mabenan

    Joined:
    Feb 7, 2014
    Posts:
    132
    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.
     
  11. SchalaZeal

    SchalaZeal

    Joined:
    May 4, 2015
    Posts:
    10
    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.
     
  12. Mabenan

    Mabenan

    Joined:
    Feb 7, 2014
    Posts:
    132
    No there are not the only thing you have to take care of are CallBacks to the main-thread from the Listener Thread.
     
    SchalaZeal likes this.
  13. TeachableNoob

    TeachableNoob

    Joined:
    Apr 23, 2015
    Posts:
    21
    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.
     
  14. PrimeTales

    PrimeTales

    Joined:
    Jan 17, 2015
    Posts:
    9
  15. TeachableNoob

    TeachableNoob

    Joined:
    Apr 23, 2015
    Posts:
    21
    Thank you Mabenan, im excited to try this out :)