Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Use DOTS with multiplayer

Discussion in 'Entity Component System' started by miyoku, Jun 28, 2021.

  1. miyoku

    miyoku

    Joined:
    Nov 13, 2013
    Posts:
    8
    Hi,

    I'm having lots of troubles with DOTS. I find it already hard to find good tutorial to use it. I'm trying to make a simulation like game. So there is lots of objects and i'd like to use DOTS for better performance. But in the same time, Unity upgraded it's multiplayer api (Now MLAPI) and i can't find any way to use them both.

    Does anyone have a idea?
     
  2. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,626
  3. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    449
    @miyoku As tertle said NetCode is Unity's newest multiplayer system and it runs entirely within ECS. I've played with it a bit.

    Few things to watch out for.

    1. It is a bit finicky. You have to use 2020.1.9+ and Standard Renderer. URP is not supported yet since it uses multiple worlds and then your rendering gets all messed up.

    2. It's a bit confusing if you are newer to DOTS. To set up networking components, you'll add a tag to an entity which will then execute some information against a entity (like adding a proper component) and then destroy the tag.

    3. It is very barebones. Since it is new, it doesn't have a ton of nice to have things. But the core is there and very good.

    Here is a post about some of the things that the base tutorial isn't up to date (and I think how to fix them). And you'll see some of the issues I ran into.

    https://forum.unity.com/threads/is-the-getting-started-in-the-doc-updated.1106816/#post-7128899

    This is another great really in depth tutorial (other than Unity's standard one) but it is looooooong.

    https://moetsi.gitbook.io/unity-dots-multiplayer-xr-sample-project/dots-netcode/overview
     
    Tony_Max and WAYNGames like this.
  4. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Can you explain a little more about this? I made a test game with DOTS Netcode and both URP and HDRP (separately) and didn't notice issues
     
  5. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    449
    @PhilSA I read somewhere that URP can't render multiple worlds (since the server and the client sets them up) and that was causing issues where no entities would appear. It was my first attempt to set up DOTS Netcode and lots of stuff went wrong so maybe URP works okay.

    I think I had Unity 2021 as well, which may have been the cause of not being able to use URP. But I am not sure.

    I can't find where I found the info that URP doesn't support multiple ECS worlds. So maybe I imagined it.
     
  6. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I see, in my project I skipped the whole "test multiple client/servers in editor" feature, so that could be why I never noticed the issue. Basically, I only ever tried playing with one world active at a time (either just server, or just client, or client+server in same world)
     
  7. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    449
    Ahh, well that makes me feel better. Every time you create a fake client, it creates another world. You can flip through them too which is pretty cool for testing.
     
  8. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    449
    I did try using just one client + server as well, and was having major problems. There is a post around here somewhere about URP not working well with multiple ECS worlds. But if you can get it working with lots of ECS worlds, I would be pumped!
     
  9. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Actually wait, I just checked again and I do get multiple worlds at the same time (I was misremembering). But what's peculiar is that it looks like My ClientWorld and ServerWorld are "linked" to the DefaultWorld somehow? Notice how the Server/Client groups are also in DefaultWorld, and the systems in Server/ClientWorlds have a "(Default World)" at the end of their name

    No idea what's going on here honestly, but it appears to be working

    Default World


    Client World


    Server World
     
  10. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    449
    Well that is great. Things are working dandy right now with the Build-In Shader so I am going to keep that but I'll definitely switch to URP at some point in the future.

    I am still pretty new to this version of ECS so maybe I messed something up here. Last time I looked at it was 0.4 and the URP was still LWRP.
     
  11. uotsabchakma

    uotsabchakma

    Joined:
    Sep 17, 2019
    Posts:
    93
    Is URP fixed with dots?
    it is 2023 and I don't understand if URP support for Dots are there.
     
  12. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    449
    I am pretty sure URP is the only way to do ECS graphics.
     
    uotsabchakma likes this.
  13. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,653
    HDRP as well
     
    uotsabchakma likes this.
  14. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    449
    Oh good, I am glad they have put that in. I haven't been following ECS as closely as I had before.
     
  15. SunriseEUW

    SunriseEUW

    Joined:
    Oct 30, 2022
    Posts:
    3
    Öhm what is ECS graphic?
     
  16. FaithlessOne

    FaithlessOne

    Joined:
    Jun 19, 2017
    Posts:
    257
    Source: https://docs.unity3d.com/Packages/com.unity.entities.graphics@1.0/manual/index.html