Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Will Unity ever have a Server product?

Discussion in 'Multiplayer' started by boby-bobs, Jul 25, 2015.

  1. boby-bobs

    boby-bobs

    Joined:
    Oct 18, 2013
    Posts:
    53
    I am making a multiplayer card game and I enjoy the ease of using Unity and just programming the game logic. My game is multiplayer and from what everyone tells me, using client-server to client allows cheating, and of course if the client-server drops the game is over.

    I tried my hand at Photon Server for the last month but am insanely lost within its complexity (cannot figure out where the hell the game logic goes, to start). Will Unity be releasing a product of some sort where a server contains the game logic and Unity is just the client?
     
  2. Christian-Tucker

    Christian-Tucker

    Joined:
    Aug 18, 2013
    Posts:
    376
    I would recommend writing your own server in Java (Because it's simple and with the Java NIO2 and the ByteBuffer classes it's really, really hard to not catch on if you know anything about primitive types). A card-game doesn't rely on physics so you'd really just be checking some basic information about the player. I can write a basic card-game server in Java in about 30 minutes. (This is if you're going to be a single server handling match-making and hosting the games yourself, such as blizzards title hearthstone). It's very simple to scale the JavaNIO2 framework to thousands of concurrent connections. You can make use of the JooQ SQL library (semi complicated) and the CompletionHandler added in Java8 to have semi-asynchronous SQL database calls.

    For client-side communication you'd make use of the TcpClient that comes with .NET and a MemoryStream (which will help with the prevention of TCP segmentation). Sending basic data over the network is all that would be required, in the event of "summoning a monster" in a card-game like yu-gi-oh you would just send the card-id to the server, with the reques-id(summon) and the server would handle everything and say yes or no.

    If the server says you can summon the monster, it tells both clients that you summoned the monster and the proper animations are played. Rotating the table (in a two-player card-game) simplifies the animations, as you can play the same animation without any additional factors and the camera will do the rest.
     
  3. boby-bobs

    boby-bobs

    Joined:
    Oct 18, 2013
    Posts:
    53
    30 minutes? How long have you been programming ! It took me 30 minutes to try and read Photon's Hello World guide. Why Java over C#? I'm comfy in C# at this point.
     
  4. Christian-Tucker

    Christian-Tucker

    Joined:
    Aug 18, 2013
    Posts:
    376
    Personal preference. I haven't seen any asynchronous channel implementations in .NET that weren't over-complicated. Photon was seriously over-complicated in my opinion which is why I ended up writing my own networking for my games. Java and C# however are very similar in programming styles, both are object oriented and while Java is a bit easier (in my opinion) and I feel like it's a stronger language overall. (Warning, incoming fan-soldiers to prove me wrong.)

    "How long have you been programming?": A few years as a hobbyist.
     
  5. boby-bobs

    boby-bobs

    Joined:
    Oct 18, 2013
    Posts:
    53
    If I want to do this, do you have any recommendations on where to start? I don't know Java and I really like C#... I know MySQL and I'm assuming I can keep stats in there for my players via C#.

    What would the bare minimums for a card game be?

    Server
    ---------
    Unity connect to server
    Server place client in lobby
    Lobby place client in game
    Game logic starts
    Server send info to client about game params
    Unity update game view
    Client ask server to perform action
    Server validate action
    Unity update game view
     
  6. Disastorm

    Disastorm

    Joined:
    Jun 16, 2013
    Posts:
    132
    It may be worth mentioning that the format and syntax of Java is almost the same as C#. Which is better for this purpose, I don't know? I imagine there are good solutions in both languages.

    Additionally, it may also be worth mentioning that if you write your own server, you'll probably need to learn UNETs Low Level API as opposed to using the High Level one.

    Overall, though I do think the idea of making your own server for a non-physics based game sounds good.
     
  7. JamesPro

    JamesPro

    Joined:
    Mar 5, 2012
    Posts:
    509
    Personally If your comfortable with C# I'd go with Lidgren for the Server and just make the server a basic Console Application.
     
  8. g_a_p

    g_a_p

    Joined:
    Mar 16, 2015
    Posts:
    279
    <ShamelessPlug>
    Why writing your own Java server when there're already made ones, done by people with 10 years of experience in the field?
    www.smartfoxserver.com
    </ShamelessPlug>
    :)
     
  9. boby-bobs

    boby-bobs

    Joined:
    Oct 18, 2013
    Posts:
    53
    Since you're plugging it, I hope you are inclined to respond:

    Exactly how fast can I go from smartfoxserver setup to tossing in my game logic and sending messages back and forth between server and client? Let's just say I gave up with Photon Server due to complexity (and lack of network programming experience).
     
  10. g_a_p

    g_a_p

    Joined:
    Mar 16, 2015
    Posts:
    279
    Sure, no problem.
    Setting up SmartFoxServer is a matter of 5 minutes tops. Download, install. Done.

    In order to jump into the code and start learning from examples we provide a Unity Example Pack here:
    http://smartfoxserver.com/download/sfs2x#p=examples

    which contains lots of demos sorted by complexity level. You start from a basic connection, a basic Lobby, a turn-based game etc... up to a fully fledged FPS and other similar real-time type games. Each example is also accompanied by a tutorial found here:
    http://docs2x.smartfoxserver.com/ExamplesUnity/introduction

    To start writing server side code you can learn the essentials in this 12 minutes step-by-step video:


    Hope it helps
     
  11. boby-bobs

    boby-bobs

    Joined:
    Oct 18, 2013
    Posts:
    53
    Thanks, I will check it out