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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Showcase 1.0.0-pre.65: Short guide for creating fully working builds

Discussion in 'NetCode for ECS' started by Occuros, Mar 31, 2023.

  1. Occuros

    Occuros

    Joined:
    Sep 4, 2018
    Posts:
    287
    In the current release, there are some issues that prevent making fully working builds (and some of them can also affect the editor gameplay).

    But thanks to the fast investigation by @CMarastoni, there are workarounds that allow you to make a fully working build. This guide should contain all the steps needed in one post, so less searching is required on the forums if you run into similar issues that we have.


    1. Subscene ghosts aren't synced up:

    Inside the `PreSpawnedGhostsBakingSystem.cs => lines 55, 56` comment out the following lines
    Code (CSharp):
    1.  
    2. //var archetypeStableHash = EntityManager.GetStorageInfo(entity).Chunk.Archetype.StableHash;
    3. //hashData.Add(archetypeStableHash);
    4.  
    Replace them with

    Code (CSharp):
    1. var ghostType = ghostAuthoringBakingData.GhostType;
    2. hashData.Add(ghostType.guid0);
    3. hashData.Add(ghostType.guid1);
    4. hashData.Add(ghostType.guid2);
    5. hashData.Add(ghostType.guid3);
    6. hashData.Add(archetypeStableHash);
    7.  
    For this to work you will then also need to have a system which sets the DynamicAssemlyList to true:

    Code (CSharp):
    1.  
    2. [WorldSystemFilter(WorldSystemFilterFlags.ClientSimulation | WorldSystemFilterFlags.ServerSimulation | WorldSystemFilterFlags.ThinClientSimulation)]
    3. [UpdateInGroup(typeof(InitializationSystemGroup))]
    4. [CreateAfter(typeof(RpcSystem))]
    5. public partial class SetRpcSystemDynamicAssemblyListSystem : SystemBase
    6. {
    7.     protected override void OnCreate()
    8.     {
    9.         SystemAPI.GetSingletonRW<RpcCollection>().ValueRW.DynamicAssemblyList = true;
    10.         Enabled = false;
    11.     }
    12.     protected override void OnUpdate() { }
    13. }
    14.  

    2. Clients don't connect to your server

    Inside the `NetworkStreamDriver.cs` file around lines 82/83 add the lines to return the endpoint directly if it is a client.

    Code (CSharp):
    1. private NetworkEndpoint SanitizeConnectAddress(in NetworkEndpoint endpoint, int driverId)
    2. {
    3. #if UNITY_CLIENT
    4.   return endpoint;
    5. #else
    6.   ...
    7. #endif
    8. }

    These changes should be enough to have a fully working version with pre.65. All of these require that the netcode package is modified, which means you need to copy/paste it from the `Library\PackageCache` folder to the `Packages` folder (where you have the packages manifest.json).


    Hope that helps anyone which uses the latest release.