Search Unity

Question Quantization of Translation and Rotation

Discussion in 'NetCode for ECS' started by Occuros, Apr 23, 2021.

  1. Occuros

    Occuros

    Joined:
    Sep 4, 2018
    Posts:
    300
    Netcode Version 0.6:

    I try to follow the documentation to modify the default values of translation and rotation of ghost prefabs:

    - Created a class which implements IGhostDefaultOverridesModifier
    Code (CSharp):
    1. public class NetcodeOverwrites : IGhostDefaultOverridesModifier
    2.     {
    3.  
    4.  
    5.         public void Modify(Dictionary<string, GhostComponentModifier> overrides)
    6.         {
    7.             var transOverwrite = new GhostComponentModifier
    8.             {
    9.                 typeFullName = "Unity.Transforms.Translation",
    10.                 attribute = new GhostComponentAttribute{PrefabType = GhostPrefabType.All, OwnerPredictedSendType = GhostSendType.All, SendDataForChildEntity = false},
    11.                 fields = new[]
    12.                 {
    13.                     new GhostFieldModifier
    14.                     {
    15.                         name = "Value",
    16.                         attribute = new GhostFieldAttribute{Quantization = 10000, Smoothing=SmoothingAction.InterpolateAndExtrapolate}
    17.                     }
    18.                 },
    19.                 entityIndex = 0
    20.             };
    21.  
    22. overrides.Add(transOverwrite.typeFullName, transOverwrite);
    23.                
    24.             var rotOverwrite = new GhostComponentModifier
    25.             {
    26.                 typeFullName = "Unity.Transforms.Rotation",
    27.                 attribute = new GhostComponentAttribute{PrefabType = GhostPrefabType.All, OwnerPredictedSendType = GhostSendType.All, SendDataForChildEntity = false},
    28.                 fields = new[]
    29.                 {
    30.                     new GhostFieldModifier
    31.                     {
    32.                         name = "Value",
    33.                         attribute = new GhostFieldAttribute{Quantization = 1000, Smoothing=SmoothingAction.InterpolateAndExtrapolate}
    34.                     }
    35.                 },
    36.                 entityIndex = 0
    37.             };
    38.             overrides.Add(rotOverwrite.typeFullName, rotOverwrite);
    39.            
    40.         }
    41.  
    42.         public void ModifyAlwaysIncludedAssembly(HashSet<string> alwaysIncludedAssemblies)
    43.         {
    44.         }
    45.  
    46.         public void ModifyTypeRegistry(TypeRegistry typeRegistry, string netCodeGenAssemblyPath)
    47.         {
    48.         }

    - Created a .NetCodeGen assemply definition file:

    filename: NetcodeOverwrites.NetCodeGen

    netcodegen.PNG
    folderexample.PNG


    But I still have the same quantization values for translation and rotation.

    What step am I missing? (In previous netcode version I managed to modify it, but not since 0.6)
    translationquantization.PNG
     
  2. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    896
    Seems like to me that the assembly name is wrong. The filename looks correct but the the name should be NetCodeOverwirtes.NetCodeGen. Instead, the inspector show something like NetcodeOvewrites.NetCode. Please verify that.
    And of course, the class that implements the IGhostDefaultOverridesModifier must be in that assembly.