Search Unity

Unity Helper lib...

Discussion in 'Multiplayer' started by Tomo-Games, Apr 13, 2013.

  1. Tomo-Games

    Tomo-Games

    Joined:
    Sep 20, 2010
    Posts:
    223
    Hi All

    I suppose if I want to control NPC moment on a .Net based central server (let us exclude the Networking framework choice for now) what lib would work best to mimic Unity Transform translations since not all of us are going to run a headless unity build? Say it handles the basics such as Vector3 math, Quarternion and such. As it stands now the UnityEngine.dll is only a wrapper for Unity's native C++ so it maybe helpful for the community to create our own clone lib (minus the graphics renderer) much like what the XNA Community did for porting the Microsoft XNA 4.x Framework to MonoGame. I know this task is easier said then done if we take into account things such as Physics, Basic to Advanced Mesh Colliders, Raycasts and such. If there already are some libraries out there that can be used in conjunction with Unity's player we should be tracking these efforts for ourselves. I started to write my own and then thought I should check with the community as well.

    Any thoughts? Thanks.
     
  2. appels

    appels

    Joined:
    Jun 25, 2010
    Posts:
    2,687
    I'm not sure why you post this in networking, also there are some good alternatives around for free ( Jitter, ... )
     
  3. Tomo-Games

    Tomo-Games

    Joined:
    Sep 20, 2010
    Posts:
    223
    Jitter is a good example. I suppose the goal would be to wrap up and combine existing frameworks to retrofit Unity's framework for external use cases. Networking being the biggest supporter for being a headless application.
     
    Last edited: Apr 13, 2013
  4. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    "what lib would work best to mimic Unity Transform translations since not all of us are going to run a headless unity build?"

    Interesting question.

    When I build a server, that's not headless, I ask a different question: What functionality do I need? From there, I build my server and simply let the client use its framework to best present the information I provide.

    As a stupidly simple example, consider chess. In the Unity
    environment I need transforms with scaling, positions, rotations, I need animations and particle effects etc. On the server however, all I need is a simple byte array. While simple, I'd apply the same logic when creating a FPS or a RTS.

    TL;DR The client mimics the server, not the other way around.
     
    Last edited: Apr 14, 2013
  5. Tomo-Games

    Tomo-Games

    Joined:
    Sep 20, 2010
    Posts:
    223
    Yes but in this situation let us assume the network engine doesn't provide any game related API aside from relaying your packets data... Hence why I would like to avoid the whole network topic battles that go on in here.
     
  6. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830

    As the server programmer, it's up to you to implement it. However, you'd be implementing the code to create the server representation of the game state - not trying to mimic unity [which is just one client that presents your game state].

    Basically if you want to base your server code off of Unity API's - use photon cloud, uLink, pikko,
    badumna etc. If you're going with a custom .net solution it's because the Unity API's do not fullfil your needs, and as such trying to reimplement them is counterproductive. Why are you trying to reproduce something that doesn't match your needs?

    I'm genuinely interested in your rationale, as I've got a custom server and am in the process of building up API's for it.
     
  7. Tomo-Games

    Tomo-Games

    Joined:
    Sep 20, 2010
    Posts:
    223
    Ah ok. Well I would like to achieve keeping most of the game logic developed inside Unity but would like to see that same in game behavior to be ported in a mono .Net environment once that game goes multiplayer without needing to refactor all of one's code. Let's take Badumna running a Seedpeer on Ubuntu for example which uses P2P we could stick to Unity's API to sandbox game logic from client to client as you say however if I wanted to run my own master peer in Mono .Net as an authoritative server I would loose access to all that work that was built from Unity as the API is no longer available. There may be other use cases where some minor game logic can run client side. Having the option to go both ways is an interesting one. If I can build a wrapper and keep the networking framework somewhat agnostic it might be easier to port a larger percentage of the same game to photon if my server platform goes to windows. Or I could port the game to lidgren or some other high level network framework. There are other benefits to allow some of the Unity API for mono .Net if it honors WYSIWYG in Unity. Obviously this isn't as simple as plug and play. I would still need to write all of the data types and Network optimization code for transmitting the game state to the clients (byte array with enum UP,LEFT,RIGHT,DOWN etc...). The only main difference here is that the server side code to move the player may be doing a traditional transform.Translate or a rigidbody.AddForce or whatever Unity based call that strikes the developers fancy.
     
  8. Tomo-Games

    Tomo-Games

    Joined:
    Sep 20, 2010
    Posts:
    223
    Note: this is also why many open and commercially successful network frameworks have various XNA framework examples included with the kit. We as a community should have our own strong following but that door is closed for now...
     
  9. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Nope. If you want to use the Unity API on the server... the quickest way is to run Unity on the server.

    This is the case regardless of what API's are used.

    Which is *already* supported using various existing paradigms.

    I guess I'm having to find a hard time finding a use case where:

    • The existing Unity based solutions API's aren't good enough. [Photon Cloud, Hybrid Server [e.g. Photon Server + Unity Headless], Badumna, uLink, Pikko, Unity Builtin].
    • So we've decided to go purely .Net/C++/Erlang etc.
    • But still want the exact same characteristics as Unity!
    And while it's not that much code to create a physics simulation server-side that can recreate this basic environment... unless you can get a license to the version of Physx Unity has, with any changes/modifications they've made, and reimplemented Unity's API implementation perfectly... you won't have even 'copied' it correctly.
     
  10. Tomo-Games

    Tomo-Games

    Joined:
    Sep 20, 2010
    Posts:
    223
    All that you said requires running a Unity Pro headless server license. This won't grow nearly as big as XNA clones did for the indie community.
     
  11. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    Nope.
     
  12. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,124
    Guys
    First of all the guys at MuchDifferent are in the process of making something called uServer which is exactly what you are talking about. It will not be free or open source i think but it will be available.
    Secondly i think a better way is to run existing math libraries in unity and server instead of cloning unity on the server.
    Also if the game is highly physics based then you need to implement a physics system which you can simulate it in different time frames by yourself. the book AI game engine has good chapters on sports games and racing games which talks about them and their networking characteristics as well.
     
  13. Tomo-Games

    Tomo-Games

    Joined:
    Sep 20, 2010
    Posts:
    223
    Thanks Ashkan_gc for your feedback. I haven't heard anything officially about uServer yet. That would be a plus. As it stands I think most Unity based game servers are limited to running headless aka -batchmode on windows machines (I'm still living in Unity 3.5). To write our own .Net server would require adding some level of physics even if it's just calculating simple collision triggers in world space. Obviously as one factors in all the needed libs to make a .Net solution more viable (while keeping all of it's functionality separate) it adds to the documentation conundrum for detailing how it would work tying all the components together (like converting a Matrix in one lib to a Quaternion in another). Of course every lib has it's own learning curve if the docs are even being provided. Factor in the duplicate queries that goes into these forums. It might be nice to kick them to the Unity docs or some kind of familiar standard.