Search Unity

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

Discussion in 'Assets and Asset Store' started by mischa2k, May 1, 2020.

  1. WildMaN

    WildMaN

    Joined:
    Jan 24, 2013
    Posts:
    128
    Any estimates for the larger structs w/buffers and CCU test ? Like in a month or in a year?
     
  2. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    What do you mean with larger structs w/buffers?
    CCU test in a few months. Not in a rush, plenty of core work to finish which would require redoing the CCU test anyway :)
     
  3. ozodic

    ozodic

    Joined:
    Jan 3, 2019
    Posts:
    6
    is it possible to add an offset to the synced transform so that the local player on the client side is always at 0,0,0 while on the server/to everyone else the clients position is something else?
     
  4. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Origin shifting is not support by DOTSNET.
    But maybe it's possible anyway. Never tried that method myself.
     
  5. ozodic

    ozodic

    Joined:
    Jan 3, 2019
    Posts:
    6
    Thank you. What system handles the positions of networked objects?
     
  6. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
  7. IliqNikushev

    IliqNikushev

    Joined:
    Feb 1, 2017
    Posts:
    23
    Hey hey, I am developing my game with Mirror (awesome btw)
    But i got to a point where i have more than 10k objects and it is becoming laggy, so i switched to DOTS
    Found out about this package and tying in things now

    I am having an issue with the Physics example
    I created an empty Unity Project, imported DOTS (it installed all dependencies)
    And when i open the Physics example, Start Server, Connect Client i get

    Code (CSharp):
    1.  
    2. System.IndexOutOfRangeException: Index {0} is out of range of '{1}' Length.
    3. This Exception was thrown from a job compiled with Burst, which has limited exception support.
    4. 0x00007ff8a5fb147e (6ddfc965240ea624a50b1743cc6a625) [unknown:0] Unity.Jobs.IJobExtensions.JobStruct`1<Unity.Physics.Broadphase.StaticVsDynamicBuildBranchNodePairsJob>.Execute
    5. 0x00007ff8a5fb1011 (6ddfc965240ea624a50b1743cc6a625) 8A75A23187CC3954
    6. 0x00007ff6cc34e050 (Unity) ExecuteJob
    7. 0x00007ff6cc34f0df (Unity) ForwardJobToManaged
    8. 0x00007ff6cc34a530 (Unity) JobQueue::Exec
    9. 0x00007ff6cc34a7ea (Unity) JobQueue::ExecuteJobFromHighPriorityStack
    10. 0x00007ff6cc34ad79 (Unity) JobQueue::ProcessJobs
    11. 0x00007ff6cc34cddf (Unity) JobQueue::WorkLoop
    12. 0x00007ff6cc53fc07 (Unity) Thread::RunThreadWrapper
    13. 0x00007ff97c1e7034 (KERNEL32) BaseThreadInitThunk
    14. 0x00007ff97da22651 (ntdll) RtlUserThreadStart
    I followed this recommendation

    https://forum.unity.com/threads/202...array-and-deferred-jobs.1225635/#post-7815393
    and the example started working

    Code (CSharp):
    1.  
    2. - go into YOURPROJECTLibrary/PackageCache/
    3. - copy com.unity.collections@0.15.0-preview.21 into YOURPROJECT/Packages/
    4. - open com.unity.collections@0.15.0-preview.21\Unity.Collections\NativeList.cs
    5. - change line 599 from Allocator.None to Allocator.Invalid
    Is there a better workaround? :3
     
  8. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Did you use exactly the Unity & packages versions recommended on the asset store page?
     
  9. IliqNikushev

    IliqNikushev

    Joined:
    Feb 1, 2017
    Posts:
    23

    yup
    I freshly installed Unity 2021.2.9 created a pure empty 3d project, added DOTSNET and
    DOTSNET installed the dependencies it needed, i'm guessing there is a specific .preview version that needs to be pinned, but not all of them have other versions
    upload_2022-2-6_11-16-10.png

    upload_2022-2-6_11-16-42.png


    What i have is:
    Unity 2021.2.9
    Burst 1.6.3
    Entities 0.17.0
    Hybrid Renderer 0.11
    Physics 0.6.0

    and the custom edit of the Collections , to use the allocator.invalid
    upload_2022-2-6_11-11-14.png
     
    wooolly likes this.
  10. wooolly

    wooolly

    Joined:
    Aug 12, 2017
    Posts:
    9

    I can confirm, I exhibit the exact same bug.
     
  11. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    I'll take a look this week. Might need to downgrade Unity or packages again. Will let you all know soon.
     
    IliqNikushev and wooolly like this.
  12. IliqNikushev

    IliqNikushev

    Joined:
    Feb 1, 2017
    Posts:
    23
    On a side note, i've been playing around with DOTSNET and well...

    I'm really happy with DOTSNET :)

    Super easy to work with, really well documented and easy to get into

    Thank you for also providing the source code! :)
    I adjusted some of the code to fit my use case and it is super easy to debug and write performant code!
    I'm doing things in a Space environment (debree, asteroids, projectiles)
    Mirror does a great job, but after 10k objects, the game (not mirror) started to lag (#physics and many updates just dont scale :/)
    DOTS solves the issue and i can easily work with 100k objects now

    What i'm doing is basing the InterestManagement System on the Location of the Camera of a player + player owned objects at that area (no need to show what's at the other side of the universe, even though you have a ship there)
    And i've changed the LocalWorldStateMessage to not care about what was removed/added/kept, to just send the current snapshot of All things that the interest system finds to be observed and then the client unpawns them after a delay (showing like a ghost like figure where it was) (Something i wanted to do on my Mirror setup and did here in a minute :) )

    Review posted, one of my best purchases : partyparrot :
     
    Last edited: Feb 17, 2022
    mischa2k and exiguous like this.
  13. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Can confirm.
    I reported it to Unity, but they don't really update DOTS packages anymore so don't hold your breath.

    You mentioned you used Mirror before, I would recommend to keep using it.
    Some day Unity will update DOTS again. At the state it's in now, it's just pointless tbh.

    I've added a readme to the physics example so people know what's up next time.
     
    Last edited: Feb 19, 2022
    IliqNikushev likes this.
  14. IliqNikushev

    IliqNikushev

    Joined:
    Feb 1, 2017
    Posts:
    23
    Hmmm
    DOTSNET so far is working nicely. I am still getting things together, but in general i see an improvement in performance of at least 10x using DOTS vs monobehaviour
    I was experiencing a huge slow down when instantiating a simple asteroid 10k times. They had their own Update functions to rotate and it was slowing down the game even more and combined with Mirror having to sync the transforms - on the server i had about 10 FPS running standalone

    now i am playing around with 30k asteroids, i get solid 60fps using physics in the Editor
    if i remove physics i can have 300k asteroids at 60fps

    On the monobehaviour approach i even tried resorting to making things into standalone classes and putting their update logic into a dedicated Thread (the same way DOTS does it with ScheduleParallel)
    It worked, but it removed physics, i would have to implement NetworkTransform on the standalone classes and whenever an object was near another - i would have to instantiate it to see if it is colliding --- long story short - a lot of work

    One of the benefits of DOTS is the out of the box BURST code compatibility and it warns if you it cannot be bursted

    For that part, DOTS really performs well. Is there something i'm missing?
     
  15. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Yes, it's extremely fast. As in millions of networked entities :)
    Only problem is ECS has not received any updates for a year.
    DOTS team has been radio silent for the most part.

    It's difficult to believe in the tech if you can't believe in the devs.
     
    exiguous and IliqNikushev like this.
  16. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
  17. IliqNikushev

    IliqNikushev

    Joined:
    Feb 1, 2017
    Posts:
    23
    It has been an adventure to play around with DOTS and DOTSNET

    I am Really pleased with the results and i saw entities framework v 0.50 is in the works https://docs.unity3d.com/Packages/com.unity.entities@0.50/manual/index.html
    My hopes for DOTS are not dead : partyparrot :

    In my adventure so far i've got
    - Saving/loading the world (now need to make it in chunks, because saving 20k objects takes 4 seconds :confused:
    - SerializeAll to update the writer only if there was a change to an entity's components
    - SerializationWriter only for owned values (like a player's waypoints) (essentially a Writer that has 100% of properties and the default writer takes only those that are not owned)
    - nested components (like turrets, similar to how the NetworkTransformChild in mirror works)
    - Code generator for Mirror - DOTSNET
    - - if a field has a Mirror.SyncVar - create a corresponding DOTS struct to encapsulate it, and attach it in the conversion
    - - WIP if a field has a Mirror.SyncVar AND is is Array/List or is SyncList - send a message ( a bit tricky, as IComponentData needs blit type, so those variables need to be in a different storage format)
    - - WIP if has Commands, RPC and TARGET attribute - use Message System

    What would be the best way to share this? Make a package for the store?
    I saw the roadmap and these features could also fit nicely in the DOTSNET package itself
     
  18. mario012

    mario012

    Joined:
    Mar 26, 2014
    Posts:
    16
  19. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
  20. SpindizzyGames

    SpindizzyGames

    Joined:
    Jun 29, 2017
    Posts:
    108
    The announcement of Entities 0.50 says it requires Unity 2020.3.30 / 2020 LTS and support for later LTE versions will come Q2 and on. The DOTSNET product page says requires "exactly Unity 2021.2.9". Does that mean you're going to go back to version 2020.3.30 ?
     
  21. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Upgrading to DOTS 0.50 almost finished.

    Yes, only 2020.3.30 works with DOTS 0.50.
    Probably going to update to 2021 again when DOTS 0.51 is out, as 2020 is near unusable on apple silicon.
     
  22. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    DOTS 0.50 update should be out in a few minutes. note that I can't benchmark against previous version because Unity 2020 doesn't run natively on apple silicon, it's very slow on my machine.

    2022-03-30_23-50-10@2x.png
     
  23. drbatuira

    drbatuira

    Joined:
    May 4, 2020
    Posts:
    23
    Hello.
    I'm developing a game with cars, each room must have a maximum of 64 players, with a general/regional lobby.
    In this case, would it be interesting to use Mirror and then migrate to DOTSNET or would it be the case of starting directly?
    ( I don't have knowledge with Dots/ECS, I can learn, but it's not my reality yet)
    Thank you so much for your assets
     
  24. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Just use Mirror + GameObjects.
    Imho avoid DOTS where possible unless you have no choice.
     
    dannyalgorithmic and drbatuira like this.
  25. aggaton

    aggaton

    Joined:
    Jul 3, 2021
    Posts:
    113
    I downloaded the package in a fresh unity 2020.3.30f1 project and it automatically installed the requisites (except URP which was installed at version 10.8.1, doesn't let me pick 0.50 which the asset store page mentions. Not sure if that is the issue I have, which is, when I try to run your example scenes, all I get is a blue screen with nothing happening. There is no error in the console log, just a message saying requesting to spawn player, then nothing until I disconnect and stop the demo.
     
  26. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Oops, that's not right. I will update the asset store page, sorry.

    Please use those:
    2022-04-17_12-33-44@2x.png
    This works in on my machine :)
     
  27. heesang0528

    heesang0528

    Joined:
    Apr 20, 2022
    Posts:
    1
    I get only blue screen when start(run) project. Only chat example can see chat UI layer. package install version is same as yours . no error in console.
     

    Attached Files:

  28. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    URP seems still broken.
    Nobody had those issues before switching to URP, and I would never have switched if DOTS 0.50 wouldn't require it.

    Not sure what to do about it.
    Can't downgrade since it's required.
    Can't reproduce since it works on my end.

    Maybe you could try to play around with the URP settings or reimport the whole URP package + setup?
    If you figure it out please let us know.
    Otherwise feel free to ask Unity for a refund.
     
  29. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Anyone successfully uses DOTSNET from Asset Store, or everyone has the URP issue?
     
  30. mk1987

    mk1987

    Joined:
    Mar 18, 2019
    Posts:
    53
    Hi there, im very tempted to purchase this since my game runs very heavy in DOTS but just want to confirm whether its suitable first. As a PVP simulation heavy Strategy game, my plan for multiplayer was to duplicate player inputs on the other players computers with each player running a concurrent clone of the game world. In the perfect world this should result in the same simulation for each player but of course it doesnt work that way, i was intending on checking in on unit transforms, health state etc. and check for consistency based on "some logic" i'll come up with, particularly where units are close together (away from area of interest i could do consistency checks less frequently).

    Is this something that would be well suited to DOTSNET? From what i can gather the real benefits of your approach is you can network simulations (ie. 10000 units on client side, 10000 on server side simulated and get them to interact correctly), for me thats not required but very cool none the less.

    If i've missed something obvious apologies, my dog is in a very whiney mood today which is taking away my focus (in that phase of life where she wants to hunt for a boy dog..).
     
  31. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    Sounds like you want lockstep networking.
    DOTSNET is not for lockstep :)
     
  32. mk1987

    mk1987

    Joined:
    Mar 18, 2019
    Posts:
    53
    Thanks for quick response! I'll probably still get this as it looks really good and for someone whos worked in DOTS for last year or so, potentially not too fiddly to setup and maybe use it for something else or even fully implement it as I've read mixed things on lockstep.
     
  33. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    FYI someone mentioned that if you have rendering issues, try to:
    - create a new URP(!) project
    - then download DOTSNET from the asset store.

    There's a good lockstep article from age of empires development.
    It saves bandwidth, but it's also a lot of work to get the whole simulation to be deterministic.

    Might be easier to just have more bandwidth but easier development.
    Especially since for example Epic Online Services offer a free relay anyway.
     
  34. mk1987

    mk1987

    Joined:
    Mar 18, 2019
    Posts:
    53
    Just tried the benchmark and a few example scenes with URP project and DOTSNET, works fine for me. Once ive messed around with it i'll try an import on my game and rerun the benchmark scene.

    Thanks for the tip re: Epic Online Services! :)
     
  35. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
  36. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    1) URP is horrible. I posted a long review with my experience: URP vs standard render | Page 3 - Unity Forum
    2) I've just found out about DOTSNET. I developed this network game www.dogfightelite.com and I wrote all my network code. I was thinking for the sake of not having to worry about it, to switch to DOTSNET. Questions:

    a) Suggestions about where to host for the server if using DOTSNET? I have many users spread accross worldwide. Meaning, it's not odd that I have a player in Brazil vs another in UK. My server code is pretty fast and I never hosted a Unity Server so I don't know which one works best for a Unity one.
    b. Is lag and prediction managed in DOTSNET? My game is a fast-moving object (airplanes) so I need to make a lot of predictions due to lag and lots of internal tricks. If DOTSNET can do that for me (which was a pain to write for me) it would be great.
     
  37. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    1) Yes.
    2) If your goal is not worry about it, I'd recommend GameObjects and perhaps Mirror for networking.

    a) Either dedicated server that you rent, or player hosted via relay. Epic online services relay is free. We have a transport for Mirror that you could adapt for DOTSNET (or just use Mirror really)
    b) It's not (yet)
     
  38. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    Isn't Epic service a P2P service? Meaning if you have a 50 game multiplayer, everyone is sending data to everyone and the network traffic gets crazy. Am I wrong?
     
  39. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    That's what peer to peer means, yes.
    But people seem to confuse p2p with player hosted.
    For player hosted, you need to open a port in your router so that other players can connect to a player's self hosted server on his own computer.

    To avoid the hassle with opening ports, people use relays.
    The relay that epic offers is completely free.
    It's free because of their economies of scale thanks to fortnite.

    They already make a lot of money with it.
     
  40. mk1987

    mk1987

    Joined:
    Mar 18, 2019
    Posts:
    53
    Could you give a few pointers how to adapt the Mirror to Epic Game Services module to work with DOTSNET before I get going? https://github.com/FakeByte/EpicOnlineTransport Seems like it shouldn't be too difficult as i assume at this level Mirror/DOTSNET are very similar but want to make sure I'm not missing something obvious.
     
  41. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    The main difference in Transports is that Mirror uses 1 Transport class for both server & client, while DOTSNET uses two separate classes.

    The rest of the functions are pretty much the same :)
     
  42. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    700
    Question @vis2k:
    I have around 80-200 physics worlds. (Currently porting from my own layer based custom unity physics codebase to the new 0.50, which use an ISharedComponentData for it)

    Is there anything that fundamentally speaks against a client/server model using DOTSNET where a group of servers each simulates one of these worlds? What about multiple worlds on one server, but still multiple servers (sharding)?

    Is server handoff a thing / can a client be connected to multiple servers?

    (not a feature request, more like a theory discussion)
     
    Last edited: May 18, 2022
  43. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    That's a lot of worlds :)

    For my own game I want to put all worlds into one server, so that I don't need to worry about a dozen server instances and communication within them. Although that would be better for scaling obviously.

    DOTSNET creates a client and a server world.
    It access Bootstrap.ServerWorld static in several places, so it only works with one server world atm.
    The goal was to support multiple worlds in the future, but not yet.

    Tbh I am not so sure about Unity's DOTS anymore though.
    You might be better off with GameObjects.
     
  44. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    700
    I'm back on the part of the cycle where I like DOTS again, haha. But I'll do a lot of stuff with game objects, only the mass physics and pew pew simulation is going to be in DOTS.

    And yes they are a lot of worlds but many of them only have a 0-5 dynamic and a a few static bodies and are rather sparse (hardly any collisions - a space game)
     
  45. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    DOTSNET is going to be 70% off during Unity's flash sale, starting in around 10 hours.
    Probably wise to not use DOTS yet. Just saying.
    2022-05-25 - 11-58-06@2x.png
     
    AlexHolderDev and J2T like this.
  46. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
  47. vfxjex

    vfxjex

    Joined:
    Jun 3, 2013
    Posts:
    93
    Hi,

    Can you use 2D Colliders with Dots Network?
     
  48. Azazello2020

    Azazello2020

    Joined:
    Mar 22, 2020
    Posts:
    12
    Hi!
    I see, what you can send many Entities to client, but how many clients can connect to 1 server? Unity Transport with Netcode support only 64 users or 32 messages at the same time. How many connections from different addresses and ports suport DOTSNET? Thanks
     
  49. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    CCU test is planned, but should be significantly more than 64. That was the whole point.
    That being said, I wouldn't recommend using DOTS.
    Better to use GameObjects imho.
     
  50. Azazello2020

    Azazello2020

    Joined:
    Mar 22, 2020
    Posts:
    12
    How create builds? If i using Build configuration, what option i should set for client? For Server?