Search Unity

Is the "Getting Started" in the doc updated?

Discussion in 'NetCode for ECS' started by 8bitgoose, May 9, 2021.

  1. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    448
    I've already found two issues.

    1. adding ConvertToClientServerEntity component throws a warning in the editor.

    2. The Line
     foreach (var world in World.AllWorlds)
    throws an error. I think it should be
    foreach (var world in World.All)
    .

    Just wanted to make sure I am doing everything right!
     
  2. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    448
    I am confused,

    I copied the doc as best I could, but now I am getting an error from
    var ghostCollection = GetSingletonEntity<GhostPrefabCollectionComponent>();
    . Says no Entity has been created for that to be used.
     
  3. bb8_1

    bb8_1

    Joined:
    Jan 20, 2019
    Posts:
    100
    yes the newer version of the code u can find here : https://github.com/Unity-Technologies/multiplayer/tree/master/sampleproject/Assets/Samples/NetCube and i think they use subscenes now to spawn ghosts and this chapter of manual is updated i think - https://docs.unity3d.com/Packages/com.unity.netcode@0.6/manual/ghost-snapshots.html (read entity spawning and prespawned ghosts chapters) - but i use an older version of netcode where older method still work - so maybe someone else can explain this better
     
    Last edited: May 9, 2021
  4. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    448
    Thanks for the update. I also found I was using URP which multiple entity worlds does not like, so that was where I was having some problems too!
     
  5. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    448
    I am lost. I copied as best I could the code from the documentation. I was getting no prediction and really delayed responses.

    I also think the sample netcube is no longer working. Imported the project into a brand new project and I am unable to control it. I've spent about a day on trying to get the simplest stuff working to no avail.

    Is there any good tutorials that can point me in the right direction? I can't seem to get anything working despite following the instructions rigidly.
     
  6. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    895
    What NetCode version are you targeting/using?

    NetCode 0.6-preview.7 require to use sub-scenes for authoring. The NetCode sample in the public GitHub repo https://github.com/Unity-Technologies/multiplayer should work. What kind of problem you found? What do you mean I'm unable to control it?
    If you just import the project and you have burst enabled, it may be a little slow until the burst compilation is not done, especially if you have enabled job-thread and job-debugger. But apart from that you should be able to move the cube around.
     
  7. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    448
    I am using "com.unity.netcode": "0.6.0-preview.7".

    Burst is enabled, everything is default. I touch wasd and the cube sits still.

    I also followed this tutorial

    https://moetsi.gitbook.io/unity-dots-multiplayer-xr-sample-project/dots-netcode/overview

    And got to a point where I could move the cube (because I removed all the extra stuff they were doing) except the cube didn't have prediction. So I would hit move, the cube would move slightly (by one frame) but not move beyond that until the server caught up. I had the delay set to 500ms.

    I am no slouch when it comes to this stuff. I dived heavily into ECS in 2019 and have been interested in the concept since around 2015.

    I booted up the NetCube scene this morning, and now looking into the Entity Debugger I can see that the cube data is moving, but it isn't displaying in the editor or camera view. Is there a way I am supposed to tell the editor which world to draw? And is there some good documentation on Live Link? The settings in the menu aren't immediately apparent.
     
  8. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    895
    The tutorial is pretty "heavy", meaning that is adding a lot of concept and details. But is indeed good introduction.

    We support up to 500 ms latency. If you use the playmode tools, the value you put is for both send and recv. That means to get a 500 ms you should put 250 ms. Otherwise you will have 1 sec. We don't guarantee anything work as expected beyond the 500ms.

    You should be able to use NetCube sample without any issues, but not with a 500+500 ms latency.

    No you don't need to specify witch world to render.

    There are some details in the entities-0.17 about live-link and incremental conversion that it is probably what you want to look at. https://docs.unity3d.com/Packages/com.unity.entities@0.17/manual/conversion_livelink.html

    Please avoid to open a sub-scene (by click the checkbox) once you are in playmode when using NetCode package. It is not really well supported and it is causing problem with entity spawning.
    You can can however open the sub-scene (and keep it open) before entering playmode.
     
  9. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    448
    Thanks for all the info and detailed response :).

    I think I am having a biggest issue seeing where data is updated. The relationship between your player controlled cube and how that information is sent upwards to the server, updated on the server and then sent back down to the client doesn't seem to be anywhere. Is all this information done "under the hood" and the end user doesn't have to do anything special?

    Do I not need to touch anything to do with the translation value (for example) coming from the server to my client? Is that done all automatically?
     
  10. 8bitgoose

    8bitgoose

    Joined:
    Dec 28, 2014
    Posts:
    448
    Thanks for the patience. I wiped the project clean and did the Getting Started again from scratch and it worked!

    A few things to fix up.
    1. The ConvertToClientServerEntity flow needs to be replaced with a subscene. I didn't really know what I was doing with that, but I understand now.
    2. The line
    foreach (var world in World.AllWorlds)
    needs to be
    foreach(var world in World.All)

    3. In the
    MoveCubeSystem
    , Time.DeltaTime I think needs to be replaced with
    World.GetOrCreateSystem<NetworkTimeSystem>().Time.DeltaTime;


    Although now I have a problem of slight jitter when using 100ms delay. The cube will reach it's position as predicted, but then be adjusted when the server updates the cube position. I think this has something to do with compression of floats, but I am not sure. Maybe I need a different value for Time.Delta time.

    Thanks for your patience and I hope I didn't come off like a jerk!
     
    Matt-Cranktrain likes this.