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

Netcode Issue

Discussion in 'NetCode for ECS' started by Adraesh, Jan 31, 2021.

  1. Adraesh

    Adraesh

    Joined:
    Jan 3, 2019
    Posts:
    13
    Hi guys!

    I followed the Unity Netcode guide: https://docs.unity3d.com/Packages/com.unity.netcode@0.6/manual/getting-started.html

    I have made all modifications related to the Changelog and the Upgrade guide section from here: https://docs.unity3d.com/Packages/com.unity.netcode@0.6/changelog/CHANGELOG.html

    I also have made some modifications to replace the use of the class
    ComponentSystem 
    by the latest
    SystemBase 
    class in all Systems and replace all
    PostUpdateCommands
    by the following:


    Code (CSharp):
    1. var ecb = new EntityCommandBuffer(Allocator.TempJob);
    2. Entities.WithStructuralChanges()... {
    3. ecb.AddComponent<....>();
    4. }).Run();
    5. ecb.Playback(EntityManager);
    6. ecb.Dispose();
    I am ending up with some weird behavior, as you can see in the attached video. Sometimes my standalone client is well rendering the Player sometines not:


    Another issue, it seems that if I am not forcing
    Application.targetFrameRate = 60;
    in the entry point of my game I endup with a lot of "Large server tick prediction error". What I am wondering is, is it really the right approach to force the targetFrameRate like I did?

    Thank you very much!
     
  2. Adraesh

    Adraesh

    Joined:
    Jan 3, 2019
    Posts:
    13
    Anyone playing with Netcode has an idea? :)

    Thanks!
     
  3. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    Can you try adding RequireSingletonForUpdate<
    GhostPrefabCollectionComponent>() to GoinGameClientSystem.OnCreate to see if that fixes the missing graphics on some clients?

    You should not need to use Application.targetFrameRate, and I have not seen it have an effect on that specific error. Normally you only get the prediction tick error when you are at low frame rate.
     
  4. Adraesh

    Adraesh

    Joined:
    Jan 3, 2019
    Posts:
    13
    Hi Tim!

    Thank you very much for you answer!

    I have to admit it you are the boss, the
    GhostPrefabCollectionComponent>()
    fixed the graphics/spawning issue on my standalone clients :)

    Regarding the prediction tick error, I have recorded a video to illustrate what I mean (I disabled Application.targetFrameRate). Seems to happen only when using the application in server only multiplayer mode:


    Otherwise I am very happy I managed to have made the modifications necessary to have the Unity Netcode Getting Started sample using the "new" SystemBase class for all of the systems.
     
  5. Adraesh

    Adraesh

    Joined:
    Jan 3, 2019
    Posts:
    13
    Btw Tom there is something that worries me in this specific case:

    Code (CSharp):
    1. var ghostCollection = GetSingletonEntity<GhostPrefabCollectionComponent>();
    2.             var prefab = Entity.Null;
    3.             var prefabs = EntityManager.GetBuffer<GhostPrefabBuffer>(ghostCollection);
    4.             for (int ghostId = 0; ghostId < prefabs.Length; ++ghostId)
    5. ...
    How
    EntityManager.GetBuffer<GhostPrefabBuffer>(ghostCollection);
    did not throw any error as the GhostPrefabCollectionComponent was not ready and so on
    var ghostCollection = GetSingletonEntity<GhostPrefabCollectionComponent>();
    was null?
     
  6. mrvile

    mrvile

    Joined:
    Oct 20, 2015
    Posts:
    1
    I was having the same problem, this solved it for me as well.