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

[Making a techlist] Dedicated local server possibilities?

Discussion in 'Multiplayer' started by Kirlim, May 23, 2015.

  1. Kirlim

    Kirlim

    Joined:
    Aug 6, 2012
    Posts:
    126
    Hey there!

    First of all, I'm sure people will have asked this around before. I also googled for a while, but my lack of network and licenses knowledge made it very hard to find an answer on my own.

    So here is the situation: I want to prototype a simple 4 player coop game in Unity, with the following traits:
    - The player can play single player
    - Then he can open to lan out of nothing (like in minecraft)
    - Anyone who has downloaded a valid package of the game, has the ability to create a local dedicated game server by command line. This server is most likely non-unity.

    Its a requisite for this prototype to already test a networking system with these traits... I can go with solutions without server sided physics and complex collision detection, since the game, even if the prototype proves to be good, will be really simple (in collision terms)

    I've found ElectroServer and Photon, but I'm not sure about the third trait (local unity-less dedicated server) with them. With Photon, am I allowed to distribute the server with a free license? Can these traits be fulfilled with Electro?

    Other SDKs and middleware are also welcome, though preferably free for small projects.
     
  2. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Why not Unity? Or maybe bolt? I don't think ElectroServer or Photon are good matches based on what you've said so far.
     
  3. Kirlim

    Kirlim

    Joined:
    Aug 6, 2012
    Posts:
    126
    Most likely non unity, but that is not set on stone. I've read around that it is tricky to achieve parallelism in Unity, and since you won't be using any Unity-stuff in non-main threads, a game that doesn't use physics might be better off with a server in c++ or Java.

    Also, I've read that lockstep is tricky in Unity

    I've been researching, seems like Raknet now is 2-clauses BSD, and with swig, you can actually import it as a C# + DLL in Unity.
     
  4. Kirlim

    Kirlim

    Joined:
    Aug 6, 2012
    Posts:
    126
    After 6 hours of adventure, I gotta admit that building the RakNet dll with Swig and VS Community is taughtfully frustating experience, let alone knowing if it'll work.
     
  5. Kirlim

    Kirlim

    Joined:
    Aug 6, 2012
    Posts:
    126
    I don't like to have two, let alone three consecutive messages, but since this is new information, it might be better than simply editing the previous post.

    I've managed to compile the RakNet DLL, and create the C# with Swig, and integrate the DLL and C# in Unity. With this, I did a simple mono behavior script to communicate with the c++ server, and it worked! However, it seems that the RakNet C# simply generates an awful lot of garbage collecting (900 bytes I didn't discover where it come from yet, plus 40 bytes per BitStream, it seems). Maybe it'd be possible to do it non-gc if I did a plugin to access the DLL? Not that I'll do that for a prototype, though...
     
  6. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    It is far easier to achieve parallelism in Unity than it is to build a C++ server.

    I think you're looking at the wrong end of this donkey, let's talk about what you want to achieve and then we can suggest how best to do that.
     
  7. Kirlim

    Kirlim

    Joined:
    Aug 6, 2012
    Posts:
    126
    The game is basically a top-down view game based on exploring a big map. Now answering what I want to achieve is kinda of tricky, since I'm really going the other way around - seeing what are the possibilities to then decide and design the project on top of that. The only strong desired features are the three listed ones, and that the server is as lightweight as possible, so that the player can host a dedicated server and play in the same machine if he/she wants.

    But as I have been researching around, there aren't really that many alternatives. You go full Unity, or use some middleware that licenses will drop some wanted features (like allowing players to host as many local servers as they want), go too low-level in networking, or is haunted by too much gc.
     
  8. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    I'm by no means saying this is the best method but it will certainly work. I use RakNet built to a native DLL (mingw) and expose an exported C interface to my networking API.
     
  9. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Whoa, so let's get this straight - you want to build a game? I suspect you're going to be all unreasonable and actually want people to play it?

    Okay, so it's starting to look like *shipping* the game might be a really important feature. In fact it might be the most important feature! It looks like your feature list is going to be something like (in guessed order of priority):
    1. I have to ship a game.
    2. That game must be fun.
    3. It needs to be top down
    4. It needs to have art/sound assets.
    5. It needs to be multiplayer.
    6. It needs a big map.
    7. It needs to be self-hosted by my players.
    Now I want you to look at this for one reason - note how language choice never appeared? Notice how garbage collection never appears? Notice how having a server 'as lightweight as possible' never appeared?

    You're not building a server, you are building a game. You need to pick the cheapest (in cost and dev resources) server tech that will do the absolute minimum of what you want. If it does better that's a bonus, but not necessary.

    As such you need to have a tech choosing list, again in rough order:
    1. Will this do the minimum I need?
    2. Will this solution use the least possible resources?
      1. How long for me to learn it?
      2. How long to implement it?
      3. What does it do vs what will I need to engineer?
      4. What is the testing/feedback cycle like?
      5. Can I share any resources (e.g. shared code).
    3. Will this solution enable future improvements?
    Feel free to adjust these lists to suit.

    I think it you went through your tech selection using a strategy like this, the solution would be much easier to pick.
     
    jpthek9 likes this.
  10. Kirlim

    Kirlim

    Joined:
    Aug 6, 2012
    Posts:
    126
    No need to be aggressive, man... and also, I think the deepness and meaning of the word prototype (first post) slightly differ between us. Or might it be because I carelessly wrote 'game' in the last post?

    Anyway, in your terms, our priority is like this
    1. We want to know and test techs possibilities, with the three features
    2. Then we want to know what we can do with a chosen option
    3. We will use what we've learned and apply in a highly undefined game design
    4. It will be a prototype, and we will throw stuff on the fly at it until we know if it can be good or not
    5. It doesn't need to be fun if we see it won't be achieved
    6. The prototype won't be shipped.
    7. Repeat 3, 4, 5 and 6 with new ideas that stays inside the undefined design until we get something fun, or give up. If it prove to be fun, we will redesign, re-engineer, and start from scratch with proper code, assets, development methodologies and so on.

    I hope now it is clear what I'm trying to follow.Now, if for some reason you come up to dislike this approach to find new options and check if a said undefined idea is even possible, don't take me bad, it IS a valid approach.

    And now I'll defend myself:

    I've got the feeling you assumed my objective here was to find a recipe-and-done answer that would give me a full fledged shipping quality game with an awesome design idea and a complete knowledgeable team, to build something to pay our meals and still have something to the next project.

    It might be my fault for having written in a confusing way, but this topic is to build a tech list (which also means that I carefully analysed Bolt, that I didn't know until you suggested it). There might be some genius people around the world, but as for me, the difficulty of making a "Hello World" working on my environment is part of the choice making process as often it will reveal many things about any tech. I thought RakNet would be good, for example. And I tested it. Now I'm searching for another one to also test.

    And to make it clear, no, we didn't jump into project code yet. We won't add multiplayer mid-prototype.

    TLTR:
    There are endless ways to come up and test new game ideas and possibilities, and many of them aren't directly aimed to shipping or even care about final fun or quality. And it does not mean they're meaningless, nor that anyone has or has not to follow any of them.

    Edit: changed topic title to be more accurate about what I'm looking for.
     
  11. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    No aggression, just trying to focus on what is important. The fact you're making 'prototypes' not 'games' matters little - the first and foremost priority should be delivering some sort of tangible end result. The second most priority should be achieving some measureable goal. Delivering flowers, building a bridge or making a prototype is all the same.

    For example, given this priority:

    Suddenly we have a project that's goal is to test technology. Which is good and fun and all... but of what value? I mean, you start with Unity, then try Bolt, then Photon, then ElectroServer, then a custom C++ server. But why stop there? After all the objective here is to test tech, so let's try some python, some erlang, maybe some F# and VB. Of course we need to also explore the variation in techniques, libraries, engines, os's, compilers etc.

    I'm sure that's not you want, and yes I do use some hyperbole... but on the other hand I'm literally doing what you asked - giving you a list of techs to test. Which is what I'm seeing from you - a large list of tech's most of which appear to be very poor fits to the problem as you defined it. I also see statements saying you've rejected possibilities on weird metrics such as 'haunted by gc' rather than a clear and definitive measure [latency higher than required for target gameplay].

    Now go through my priority list - you can immediately discount most of the solutions you've suggested. Why? Because all non-unity options:
    • Will take longer to learn (it's a whole new programing environment!)
    • Will take longer to implement (it's a second program!)
    • Will do less for you (they are typically quite generic).
    • Have a poor testing/feedback cycle (for a start you have to keep server and client builds in sync, and have two entire debugging systems, and may encounter entire new fields of error).
    • Have far less shared resources. [No unity functions, and if not .net harder/impossible to share code.
    The reason one *wouldn't* pick a Unity based solution is if they found it couldn't do what they needed [Will this do the minimum I need?] or was extremely difficult to work with - and I've seen nothing that suggests you've encountered either of those.

    Just for perspective - I've used Unity based solutions. I've used Photon. I've written my own custom C# servers. I've even had occasion to reimplement physics. Yet in each of those scenario's the right solution was always pretty easy to pick... because you can usually discard most options with very little effort - they all tend to have pretty clear use-cases.
     
  12. Kirlim

    Kirlim

    Joined:
    Aug 6, 2012
    Posts:
    126
    That being the case, then I take back my being defensive and say sorry.

    But to make it clear, I have not rejected a possibility by using the metric 'haunted by gc', even though it is something worth to take into account for some projects. I could (and probably should) have kept silent, but I know someone some day will google and find this topic, and it might help them to know whatever experiences I had.

    We disagree somewhat on the way the priorities are being set by you and me and how we actually interpret that order of priorities each, and what 'tangible end results' are, but that's most likely because we have an inaccurate view of what each other is thinking or trying to say, potentially because of a language barrier in the middle and contextual interpretations, and this is leading to an "off-topic" discussion. As an example, for me, "top priority" is not "project goal", but "first task to take into account". If I had to write a project goal, it would be "to make one or a set of prototypes of game mechanics based on 'basic set of concepts' game design, with desired server mechanics, and measure fun factor and team current capabilities, and their viability to work and expand in a game with used concepts and technologies". This sounds like it focus more on learning and experimenting than in producing, which is actually true, given our overall experience with multiplayer development.

    So the summary: I am analyzing choices that seem potentially viable within a range that I've set for myself. The ones that seems promising I am testing with Unity, while others I'll discard as soon as I can (i.e Photon license), and I thought that posting results would help others that ended up reading this topic by web search.

    Anyway, I just wanted to know what other programmers would be using with unity that allowed the local/dedicated server with the listed 'features' - it would save me some time from having to "discover" them.

    Edit: OP here went in with older version when I clicked 'sign in' in 'error message'