Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

DOTSNET - High Performance Unity ECS Networking from the co-creator of Mirror!

Discussion in 'Multiplayer' started by vis2k, May 1, 2020.

  1. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    V1.17 pending review (bug fix release):
    2020-08-25_11-17-15.png
     
    GilbertoBitt, PolarU and florianhanke like this.
  2. yummybrainz

    yummybrainz

    Joined:
    Jan 14, 2014
    Posts:
    67
    @vis2k looks really cool!

    Is it relatively straight forward to convert the NetworkManager in usurvival to use this?
     
    GilbertoBitt likes this.
  3. tranngochung

    tranngochung

    Joined:
    Oct 24, 2016
    Posts:
    3
    Hello, this asset is support smooth sync ?
     
  4. SocialArenaPR

    SocialArenaPR

    Joined:
    Sep 26, 2016
    Posts:
    65
    No this can not be used with uSurvival. This doesn't use the old concept of GameObjects and components. The entire project would have to be rewritten.
     
  5. yummybrainz

    yummybrainz

    Joined:
    Jan 14, 2014
    Posts:
    67
    Got it thanks
     
  6. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    AlexHolderDev likes this.
  7. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
  8. nico_st_29

    nico_st_29

    Joined:
    Mar 14, 2020
    Posts:
    7
    Does Dotsnet support animations with DOTS? Is it stable?
     
    shanepadgett likes this.
  9. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    Animations are client sided, so there should be no problem :)
     
  10. Syn0_

    Syn0_

    Joined:
    Apr 1, 2018
    Posts:
    4
    Let's test this for my ambitious project :D
     
    vis2k and dannyalgorithmic like this.
  11. Matt-Cranktrain

    Matt-Cranktrain

    Joined:
    Sep 10, 2013
    Posts:
    63
    This project looks absolutely brilliant. I hope to give it a go sometime soon!
     
  12. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    Thanks :)
    Manage expectations though. DOTS/ECS is still in preview and DOTSNET while stable, is still lacking features.
     
    Matt-Cranktrain likes this.
  13. Studiomaurer

    Studiomaurer

    Joined:
    Sep 5, 2012
    Posts:
    37
    Hi, just bought DOTSNET. It looks very promising and you absolutely should have the money to work on it full time. We need this kind of asset and its mostly been a bad idea to rely on unity.
    Not sure if I can use it for my current project though. Would it be crazy to try to make it work with the ultimate character controller? It's only a prototype, so not everything has to be perfect and server authorative. I'm just wondering about the long run... I heard somebody is working on a mirror port. If that ever is released, would it be easy to adapt it to DOTSNET?
     
  14. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    Making character controllers work well over the network is very hard.
    For Mirror, I only know of one controller that works, which is the one I made for uSurvival/uMMORPG.
    DOTSNET definitely allows you to do that, but you really need to know what you are doing to get it right.
    But sure, try and report back :)
     
  15. bartimus

    bartimus

    Joined:
    Apr 21, 2020
    Posts:
    3
    Anyone know how you would go about setting the camera to follow the player in the samples? I’m trying to figure out how you reference the camera since it’s not a traditional game object. Is it possible to convert it to an entity?
     
  16. dannyalgorithmic

    dannyalgorithmic

    Joined:
    Jul 22, 2018
    Posts:
    62
  17. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    DOTSNET V1.18 pending review.
    What a month. I hope you all enjoy libuv2k. It's the best scaling Transport for Unity by far, being able to handle 100k Entities with 60 FPS on my laptop :)

    Let me know if you have any problems.
    2020-09-25_16-23-49.png
     
  18. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    V1.18b resubmitted. Now with the libuv2k Windows DllNotFoundException fix, and without physics package upgrade :)

    2020-10-03_14-33-32.png
     
  19. voncarp

    voncarp

    Joined:
    Jan 3, 2012
    Posts:
    185
    Picked this up on sale few weeks ago. Haven’t dived into it much outside of the examples scenes. 100k entities is nice. But, that type of bandwidth/messages are going to be brutal on some devices.

    Is there a way to track messages and bytes in editor or we got to use 3rd party tools?

    Again. Haven’t spent more than a few hours playing with it. Is there any way to spread that bandwidth and messages out or do we have to script that on our own?

    Just trying to plan on my next project. 10k entities I love it. I am just having a hard time planning how to spread that out among clients.
     
  20. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    Not yet :)

    If you want a game with insane amounts of entities, then that's the price to pay :)
     
  21. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    V1.19 pending review:
    2020-10-09_09-45-00.png
     
  22. Zyblade

    Zyblade

    Joined:
    Jul 1, 2014
    Posts:
    132
    What if I don't use hybrid renderer, but gpu instancing? I made a prototype using dots and gpu instancing, learned from examples from other threads. How deep "dots networking" is bound to the hybrid renderer? I update position values through compute buffer to move dynamic units. Entities are anyways setup in a way, that natural fits the gpu array setup, so I think it should be doable without too much effort?
     
  23. FakeByte

    FakeByte

    Joined:
    Dec 8, 2015
    Posts:
    137
    Rendering has nothing to do with networking.
     
    vis2k likes this.
  24. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,483
    Been digging through it, pretty dang awesome. I'm still trying to learn DOTS to move over but this is a great example to learn from and build off.

    Thanks so much for all your work.
     
    Last edited: Oct 12, 2020
  25. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    Thanks mate :)
     
  26. Zyblade

    Zyblade

    Joined:
    Jul 1, 2014
    Posts:
    132
    Then please remove the hybrid renderer requirement if it's not related at all:
    hybridRenderer.jpg

    And btw., I know rendering has nothing to do with networking...
     
  27. voncarp

    voncarp

    Joined:
    Jan 3, 2012
    Posts:
    185
    I think the Hybrid Renderer is required in order to use DOTS.
     
  28. FakeByte

    FakeByte

    Joined:
    Dec 8, 2015
    Posts:
    137
    DOTS is the data oriented tech stack, this includes all data oriented packages, therefor you don't use DOTS, you use DOTS packages. The hybrid renderer is one of those DOTS packages and its not required for all DOTS packages, just some have it as dependency.
     
  29. Zyblade

    Zyblade

    Joined:
    Jul 1, 2014
    Posts:
    132
    Thank you for replying @voncarp and @FakeByte
    So the asset just uses some packages, which leads to some package dependencies regarding hybrid renderer. I Just wanted to be sure, there's no heavy code refactoring necessary, to work with my own rendering workflow.
     
  30. FakeByte

    FakeByte

    Joined:
    Dec 8, 2015
    Posts:
    137
    The package has demo scenes which for one would require the hybrid renderer, that could be one of the reason why its mentioned as dependency. You can always disable the hybrid renderers systems, then pick up the entities you want to render with your own system, I don't see why you would need to change a single line in the network code.

    ECS is very modular and there are almost no direct dependencies which make your use case very easy to implement.
     
    Zyblade likes this.
  31. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,483
    1 quality of life example feature request would be an example shooting a networked projectile from the player position and direction and destroying it. I edited the physics example to be a character controller, and its great, but struggling to get projectiles working right, I'll figure it out, but its taken a lot of time and I'm sure its probably 15 mins if you knew what you were doing.
     
  32. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    Yep, a few more examples and a few more basic features will be needed.
    Still spending all my time on transports these days. libuv is done and kcp will come to DOTSNET soon.
    Afterwards features/examples again :)
     
  33. Brainshack

    Brainshack

    Joined:
    Mar 1, 2013
    Posts:
    8
    Would this asset also work with other type of games from MMOs? Like for instance FPS or RTS? I am evaluating using this for an RTS, would this work out of the box or would I have to change a lot to get it working?

    Also, how easy would it be to add networking to an existing ECS game with this?
     
  34. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    Should work fine for RTS.
    For FPS you need prediction etc., which DOTSNET doesn't have. It simply syncs entities over the network :)

    I'd recommend starting with one of the DOTSNET examples and build your game on top of it.
    DOTS/ECS is still new and nobody really knows the best way to do things yet.
     
  35. dannyalgorithmic

    dannyalgorithmic

    Joined:
    Jul 22, 2018
    Posts:
    62
    Would you imagine ECS architecture would be suitable for card games with related entities? Something like X card reacts to how much mama Y character has?
     
  36. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    I wouldn't recommend using ECS unless that's your only option.
    If you aren't going for massive scale, go with MonoBehaviour instead.
     
    dannyalgorithmic likes this.
  37. dannyalgorithmic

    dannyalgorithmic

    Joined:
    Jul 22, 2018
    Posts:
    62
    Thanks, mate!
     
  38. Rekart

    Rekart

    Joined:
    Jan 13, 2020
    Posts:
    6
    I am currently developing mobile game based on DOTS. Although we have our own simple implementation now, our team is looking for existing solutions. DOTSNET looks awesome, however I am not sure about how well it fits our needs, so I have couple of questions:
    1) just for clarity - according to asset store page, DOTSNET is modular and comes as source files, so we can edit that in case if we need or use our own transport, right?
    2) documentation says that there are no support for android/IOS now. According to page in asset store, DOTSNET uses LittleNetLib low-level, which supports android/IOS. Are there other reasons for limited platform support, or I'm getting something wrong?
    3) following previous question - documentation says that android/IOS support will come later, but is there any estimations for that?
    4) our networking supports component filtering - for example we can have 10 components added to entity, but only couple of them may require network synchronization. We also use different filtering strategies, for example entity 1 have components A and B synchronized over network, while entity 2 have components B and C. This way we can avoid sending data which does not change for long periods of time. How these cases are handled in DOTSNET?
    5) we can change entity archetype, adding or removing components, and change filtering strategies for data sent over network for each entity. Can we do that with DOTSNET?
     
  39. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    Yes. Next version will also come with KCP transport, which you probably want to use.

    That's because libuv only runs on Windows/Mac/Linux and LiteNetLib while it works, is too slow for DOTSNET's extreme performance.
    KCP solves that problem because it's 100% C# and nearly as fast as libuv. So with KCP it runs on all platforms.

    KCP update should come in the next couple of days by the way. I just finished porting it to Mirror, and now porting to all my assets :)

    DOTSNET lets you decide how to sync components.
    If you want to sync Transform component, you create a TransformSyncSystem that syncs it the way you like it to be synced.
    So what you are describing is possible if you are willing to implement it.
    By default DOTSNET has a simple syncInterval.

    No.


    Btw if you are making a mobile game that doesn't have insane performance requirements, then I'd recommend going with MonoBehaviour/Mirror instead. Using DOTS/ECS for a game in production right now would be very risky and painful.
     
    Rekart likes this.
  40. Rekart

    Rekart

    Joined:
    Jan 13, 2020
    Posts:
    6
    Thanks for quick reply!
    We expect medium to high requirements for performance, and ECS as approach fits our needs rather well. But yes, we sometimes have troubles due to lack of experience with dots, faced several bugs and limitations which we had to work around.

    And one more questions I forgot to ask:
    How DOTSNET manages entity creation? I mean not just entity, but required components and their initial data.
    Does it do something like "Create entity from prefab with ID" where ID of prefab is known on both client and server? If so, how it sets initial data for prefab components, or is it outside of DOTSNET scope and should be implemented depending on exact case?
     
  41. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    Yes.
    Prefabs are GameObjects with ECS' ConvertToEntity (actually a custom ConvertToNetworkEntity) which are dragged into a prefabs list.
    Server spawns them by id from that list.
    Very simple :)
     
    Rekart likes this.
  42. qbvbsite

    qbvbsite

    Joined:
    Feb 19, 2013
    Posts:
    36
    Quick question about your 10K+ example demo's, what is exactly happening in them? By that, I mean what network traffic and such. Is each entity equivalent to a player executing a move, sending a packet to the server, and then server broadcasting that change to each entity? Or is this just a single player and the server broadcasting 10k+ NPCs moving on the server?
     
  43. FakeByte

    FakeByte

    Joined:
    Dec 8, 2015
    Posts:
    137
    Did you base the KCP transport on one of the existing C# KCP transports or did you write your own?
    I remember you mentioning that mono sockets were too slow many times on the forums, if you wrote your own how did you solve that problem?
     
  44. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    It's 10k monsters being broadcasted to one client over the local network.
    I always do this test first to optimize everything to maximum, because iteration time is extremely fast.

    CCU is a lot more time consuming, and will come soon. The next one will be with Mirror first with the new KCP transport. Afterwards DOTSNET :)

    It's based on paul's KCP Transport which is based on kcp-csharp.

    kcp-csharp is basically kcp.c translated to C# as Kcp.cs. kcp-csharp deviated from original kcp.c a lot though, which caused several bugs, performance and garbage collection issues. I went through it line by line and adjusted it to latest kcp.c from skywind's github. It works a lot better now, and it's way less opinionated. It's simply kcp.c translated line by line.

    Paul added high level connection handling, which I modified a lot for Mirror and for some of my own requirements.

    Mono's TCP sockets are beyond broken. Unusable in non-blocking mode (which is still blocking) and barely usable in blocking mode.

    UDP socket works fine though, except for that IPEndPoint allocation, But regular net/C# does that too :)
     
    FakeByte likes this.
  45. qbvbsite

    qbvbsite

    Joined:
    Feb 19, 2013
    Posts:
    36
    Gotcha, so you're moving all the Entities server-side then combing queued moves into multiple packets for the client? How many packets are your sending per move for the 10K entities? Just trying to gauge the amount of network traffic and how it would translate to CCU in the real world.
     
  46. lmbarns

    lmbarns

    Joined:
    Jul 14, 2011
    Posts:
    1,483
    I'll let him fill in the specifics but it batches updates into fewer packets, and segments the observables you're receiving updates about by distance from the player. It also can compress quaternions down to a single uint and then fill up a packet with a whole lot of them.
     
    vis2k likes this.
  47. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    V1.20 pending review:
    2020-11-03_20-10-02.png
     
  48. Rekart

    Rekart

    Joined:
    Jan 13, 2020
    Posts:
    6
    Hi!
    Finally got DOTSNET, thank you very much for huge amount of comments and explanations, found some notes about Entity bugs I had to work around previously, too)

    I have a question about World Initialization. If my understanding is correct, DOTSNET assumes that we create all 3 worlds (Default, Client and Server) when application starts, and those worlds live until application quit. However, I want more control over world lifetime - so I'm writing my own bootstrap based on what DOTSNET offers and what I had previously. For example, I want default world lifetime match application lifetime, while creating and disposing client and server worlds multiple times during app lifeteime. So I had to take a look at what happens inside Bootstrap.cs, and one thing that is not clear for me, is why using

    Code (CSharp):
    1. InitializationSystemGroup initializationGroup = serverWorld.GetExistingSystem<InitializationSystemGroup>();
    2. defaultWorld.GetExistingSystem<InitializationSystemGroup>().AddSystemToUpdateList(initializationGroup);
    instead of

    Code (CSharp):
    1. ScriptBehaviourUpdateOrder.AddWorldToCurrentPlayerLoop(serverWorld);
    If I'm understanding it correctly, such Client/Server world initialization makes them tightly dependent of Default world?

    At the moment I can manually launch Client or Server World and manually set up all specific systems, but when I try to dispose worlds created by DOTSNET bootstrap, I get exception thrown from DefaultWorld's InitializationSystemGroup:

    InvalidOperationException: object is not initialized or has already been destroyed

    which I suppose comes from fact that we added ServerWorld's InitializationSystemGroup to updateList of DefaultWorld's InitializationSystemGroup, and even trying to remove it manually before disposal doesn't seem to work for some reason.
     
  49. vis2k

    vis2k

    Joined:
    Sep 4, 2015
    Posts:
    3,715
    Did you try the second code snipped and see if that works?
    Unity changes ECS quite a lot, might be a new feature.
     
  50. Rekart

    Rekart

    Joined:
    Jan 13, 2020
    Posts:
    6
    Yep, looks like its working almost without any additional changes - just have to deal with servers's PresentationSystemGroup. Checked on several example scenes.

    Quick look at profiler shows that second snippet causes reordering of InitializationSystemGroup and SimulationSystemGroup execution order for client/server worlds - previously nested inside DefaultWorld SystemGroups, they now run outside of DeafultWorld scope. Not sure about how that going to affect performance, however.
     
    Last edited: Nov 12, 2020
    langtusaupt likes this.
unityunity