Search Unity

DOTS NetCode 0.3.0 released

Discussion in 'NetCode for ECS' started by timjohansson, Aug 21, 2020.

  1. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    A few minutes ago we published com.unity.netcode@0.3.0-preview.3 .

    This release requires Unity 2020.1.2 and entities 0.14.

    NetCode 0.3.0 is a significant change to the authoring workflows for ghosts. We now automatically generate code per component and no longer do any code generation per ghost prefab. Since it is a major change any project using earlier versions of NetCode will unfortunately have to change some code to upgrade, please see the change log for details.

    We also released com.unity.transport@0.4.0-preview.3 and updated the samples at https://github.com/Unity-Technologies/multiplayer/

    Change logs:
    https://docs.unity3d.com/Packages/com.unity.netcode@0.3/changelog/CHANGELOG.html
    https://docs.unity3d.com/Packages/com.unity.transport@0.4/changelog/CHANGELOG.html
     
    Last edited: Aug 21, 2020
    Samsle, Lionious, Orimay and 13 others like this.
  2. Lukas_Kastern

    Lukas_Kastern

    Joined:
    Aug 31, 2018
    Posts:
    97
    I'm porting my existing code base to Netcode 0.3.0 right now.
    Can someone explain the usage of the new Composite field inside the GhostFieldAttribute?

    On a different note i found out that multiple entity fields on the same component lead to the variable ghostEnt being declared multiple times inside the components serializer.
     
    florianhanke likes this.
  3. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    Is it possible that 2020.2 is behind 2020.1 in terms of DOTS support? I tried opening the sample in 2020.2 and I'm getting errors about job reflection data
     
    Last edited: Aug 21, 2020
    johnroodt likes this.
  4. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    Our new serialization code supports serializing structs, so if you can have patterns like this
    Code (CSharp):
    1. public struct SomeData
    2. {
    3.     public int A;
    4.     public int B;
    5. }
    6. public struct SomeComponent : IComponentData
    7. {
    8.     [GhostField] SomeData Data;
    9. }
    Part of out delta compression is a change mask - 1 bit per field in the component - saying if that field has changed. If it has not changed the data is not part of the snapshot. We also delta compress those change masks to make non-changing fields zero bits (there are some side effects which make subsequent changes slightly more expensive in a few cases, but generally the cost is <1bit).

    The Composite field is something you can put on the GhostField attribute for the struct (the field called Data in my example) to control if you have one change mask bit per field in the inner struct, or one change mask bit for the inner struct as a whole. In my example it's either two bits, one for A and one for B in the non-compoiste case, or 1 bit for SomeData in the composite case.
    Which is better depends on how your data is changing. If A and B usually change together it's probably better to use composite, but if one changes frequently and one rarely it might be better to use non-composite.

    Thanks, we'll fix that. It would be great if you can file a bug for it in the Unity bug reporter so we get tracking on it
     
    bb8_1 and Lukas_Kastern like this.
  5. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    We are working on fixing that and will get a netcode version with Unity 20.2 support out as soon as we can
     
    Ghosthowl, Orimay, dzamani and 3 others like this.
  6. Lukas_Kastern

    Lukas_Kastern

    Joined:
    Aug 31, 2018
    Posts:
    97
    Will do!
     
    bb8_1 likes this.
  7. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    bb8_1 likes this.
  8. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    I really like the addition of [GhostComponent] and [GhostField]. They allow me to easily make a plug-n-play NetCode integration for my package instead of having to write a big guide on which variables in my package's components have to be networked and how to setup ghosts
     
    Last edited: Aug 22, 2020
  9. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,129
    How can I add attribute to reserved IComponentData like Translation, Rotation and RenderMesh since it's being used by official?
     
    bb8_1 likes this.
  10. PhilSA

    PhilSA

    Joined:
    Jul 11, 2013
    Posts:
    1,926
    In the doc's "Getting Started", it says whenever you add a GhostAuthoring component, it automatically adds replication fields for Translation and Rotation

    But I'd also be curious to know how we can replicate other fields that weren't maked with [GhostField], but are in packages that we don't want to modify. I'm guessing that if NetCode can add those automatically, we might be able to do that as well
     
    Last edited: Aug 22, 2020
    bb8_1 likes this.
  11. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    246
    PhilSA likes this.
  12. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    Samsle likes this.
  13. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    I am wondering what
    GhostGroup
    s are exactly and how I could maybe use them.
    Code (Boo):
    1. GhostGroups are now supported. A ghost prefab can have a GhostGroup buffer added to it at authoring time, all ghosts listed in that buffer are guaranteed to be sent together with the main entity. In order to be in a group the child ghost must have the GhostChildEntityComponent component added to it. The GhostChildEntityComponent can be added at runtime when moving the child entity into the group.
    I'm guessing it's for adding virtual children to another ghost prefab… am I off the mark?
     
  14. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    Another question – how can syncing of Translation or Rotation of children be enabled, for example for a rotating turret?
    Screenshot 2020-08-23 at 20.58.27.png
    In the picture: Rotation is synced for the root, but not for child 0 (no fields are listed, and it is not rotating in the client, but it is on the server).
     
  15. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    966
    Is anyone else getting "Internal: deleting an allocation that is older than its permitted lifetime of 4 frames" warnings in the Asteroids sample?
    I'm on 2020.1.3f1
     
    bobbaluba likes this.
  16. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
    do you have vsync on

    because netcode runs at a fixed framerate, you need to limit your fps so it's not 4x higher than the update rate
    (they are looking into a way to fix this)
     
  17. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    966
    Vsync is turned on. I'm still getting more than 60+ fps shown in game stats. Isn't simulation tick rate now independent of rendering framerate?
     
  18. tertle

    tertle

    Joined:
    Jan 25, 2011
    Posts:
    3,761
  19. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    You are mostly correct, but it is important to note that the group itself is not replicated at the moment, so you can't get the list of group members on the client side - you have to add entity references to them. The main use-case it intends to solve is if you have a player and a replaceable weapon or ability owned by the player (which is not known at authoring time) and you want to make sure those two ghosts are always sent together so you know they are in sync.
     
    bb8_1 and florianhanke like this.
  20. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    You have to use the same IGhostDefaultOverridesModifier as when adding new default overrides mentioned in https://docs.unity3d.com/Packages/com.unity.netcode@0.3/manual/ghost-snapshots.html (create a class implementing that interface in an assembly with a name ending with ".NetCodeGen")

    Instead of adding a new item you modify an existing one, so in the Modify method you would do something like
    Code (CSharp):
    1. overrides["Unity.Transforms.Translation"].attribute.SendDataForChildEntity = true;
    2. overrides["Unity.Transforms.Rotation"].attribute.SendDataForChildEntity = true;
    Doing that will mean all translation and rotation components are ghosted for child entities in ghosts.

    This is not the finalized API for it and I expect the way you do this to change in the future.

    Edit: should also mention that the code is kind of pseudo-code, I did not compile and run it so you might need to change it slightly
     
    bb8_1 and florianhanke like this.
  21. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    Not that I'm aware of, VSync is generally tied to the monitor refresh rate though - so if you have a 240Hz monitor you'll get really high framerates regardless.
    Another thing you could try is setting Application.targetFrameRate = 60 and see if that helps
     
    bb8_1 likes this.
  22. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    Thanks for confirming, Tim – and thanks for the valuable "not replicated" info!
     
  23. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    Thanks! I'll give it a try – as a note on future API developments: for me, a "SendChildEntityTransformAuthoring" or similar component on the child game object would be most comfortable to use.
     
  24. Guedez

    Guedez

    Joined:
    Jun 1, 2012
    Posts:
    827
    This means that MMO is now possible? Having only players in certain zones be able to see certain ghosts?
     
  25. StickyMitchel

    StickyMitchel

    Joined:
    Sep 2, 2019
    Posts:
    19
    I might be missing a step in the upgrade but now when going into Playmode in the editor I get this error:
    Code (CSharp):
    1. GhostReceiveSystem incompatible ghost version 1575332578492845489. Server: 2200140279179422308
    2. UnityEngine.Debug:LogError(Object)
    3. Unity.NetCode.ReadStreamJob:Execute() (at Library/PackageCache/com.unity.netcode@0.3.0-preview.3/Runtime/Snapshot/GhostReceiveSystem.cs:248)
    4. Unity.Jobs.JobStruct`1:Execute(ReadStreamJob&, IntPtr, IntPtr, JobRanges&, Int32)
    In build nothing happens but it stops me from testing in Editor.
     
  26. Enzi

    Enzi

    Joined:
    Jan 28, 2013
    Posts:
    966
    Thanks!
    Setting Application.targetFrameRate = 60 works. No more warnings. Not sure why the VSync option is ignored, usually this always worked for me.
    Does this stay like that or be fixed at some point? It's not intended, is it?
     
  27. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    There are plenty of hard problems to solve in order to make an MMO, but yes - you can limit the zones sent to a player with this.
     
    Guedez and hippocoder like this.
  28. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    This indicates that the ghost collections is not the same on the client and the server. We added validation that the collection matches (before it would cause random looking errors at runtime). We still need to improve how to figure out what is different, for now you have to set a breakpoint or add logging in CalculateGhostCollectionHash in GhostCollectionSystem.cs to figure out what is wrong.
     
  29. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    It is a bug and will be fixed at some point, but I cannot say exactly when.
     
    Enzi likes this.
  30. Guedez

    Guedez

    Joined:
    Jun 1, 2012
    Posts:
    827
    Like what? I assumed that being able to limit who gets which ghosts was the only thing actually impeding to use NetCode for mmo
     
  31. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    This appears to work. For reference:
    Code (CSharp):
    1. namespace Networking.Overrides
    2. {
    3.     public class ChildOverrides : IGhostDefaultOverridesModifier
    4.     {
    5.         public void Modify(Dictionary<string, GhostAuthoringComponentEditor.GhostComponent> overrides)
    6.         {
    7.             // Overrides definition for all children to send transforms.
    8.             overrides["Unity.Transforms.Translation"].attribute.SendDataForChildEntity = true;
    9.             overrides["Unity.Transforms.Rotation"].attribute.SendDataForChildEntity    = true;
    10.         }
    11.  
    12.         public void ModifyAlwaysIncludedAssembly(HashSet<string> alwaysIncludedAssemblies) { }
    13.  
    14.         public void ModifyTypeRegistry(TypeRegistry typeRegistry, string netCodeGenAssemblyPath) { }
    15.     }
    16. }

    But sadly syncing the children's Translation and Rotation using the above method leads to the following issues (1000s of error messages). Initially:
    Screenshot 2020-08-24 at 21.51.09.png
    Then:
    Screenshot 2020-08-24 at 21.51.09.png
    I'll have to check tomorrow if it's missing render bounds or whether I'll have to also sync other transforms-related data, but if anybody has seen this and knows the issue, please let me know :)

    (Latest of URP, Hybrid Renderer, NetCode)
     

    Attached Files:

    Last edited: Aug 25, 2020
    Occuros and PhilSA like this.
  32. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    One of the bigger ones would be splitting the server simulation between multiple servers and seamlessly migrating between them so you can scale beyond what a single server can simulate. It might be possible to do with the current netcode - I haven't tried so I don't know - but building an mmo is not easy.
     
  33. cdm456852

    cdm456852

    Joined:
    Nov 21, 2017
    Posts:
    33
    Did you notice the bug that I post today? I hope you can answer it. Thank you. https://forum.unity.com/threads/new...predictedghostspawnentity-cant-detect.957404/
     
  34. Guedez

    Guedez

    Joined:
    Jun 1, 2012
    Posts:
    827
    Oh, great, that's for World of Warcraft big MMOs, probably not really needed for Eco/Wurm sized "MMO"s, specially with DOTS to make simulation super fast anyways. Considering I plan on releasing the server for players to host their own servers modded, this is even less of an issue.
     
  35. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    Sadly, I have no idea. I'll try to do a repro case.

    @timjohannson How important is the case of a networked parent with child entities for the NetCode team? A demo example would be great – I can't be the only one who wants to cover the tank body + rotating turret case…?
     
  36. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    @timjohansson While going over the Getting Started page to put together the case mentioned in my last post, I noticed some issues.
    • A script on the page references
      cube.PlayerId
      but
      MovableCubeComponent
      has no field PlayerId.
    • World.AllWorlds
      is deprecated ->
      World.All
    • This script on the page page references
      player
      , but should probably reference
      prefab
      :
    Code (CSharp):
    1. // When server receives go in game request, go in game and delete request
    2. [UpdateInGroup(typeof(ServerSimulationSystemGroup))]
    3. public class GoInGameServerSystem : ComponentSystem
    4. {
    5.     protected override void OnUpdate()
    6.     {
    7.         Entities.WithNone<SendRpcCommandRequestComponent>().ForEach((Entity reqEnt, ref GoInGameRequest req, ref ReceiveRpcCommandRequestComponent reqSrc) =>
    8.         {
    9.             PostUpdateCommands.AddComponent<NetworkStreamInGame>(reqSrc.SourceConnection);
    10.             UnityEngine.Debug.Log(String.Format("Server setting connection {0} to in game", EntityManager.GetComponentData<NetworkIdComponent>(reqSrc.SourceConnection).Value));
    11.             var ghostCollection = GetSingleton<GhostPrefabCollectionComponent>();
    12.             var prefab = Entity.Null;
    13.             var serverPrefabs = EntityManager.GetBuffer<GhostPrefabBuffer>(ghostCollection.serverPrefabs);
    14.             for (int ghostId = 0; ghostId < serverPrefabs.Length; ++ghostId)
    15.             {
    16.                 if (EntityManager.HasComponent<MovableCubeComponent>(serverPrefabs[ghostId].Value))
    17.                     prefab = serverPrefabs[ghostId].Value;
    18.             }
    19.             EntityManager.SetComponentData(player, new GhostOwnerComponent { NetworkId = EntityManager.GetComponentData<NetworkIdComponent>(reqSrc.SourceConnection).Value});
    20.             PostUpdateCommands.AddBuffer<CubeInput>(player);
    21.  
    22.             PostUpdateCommands.SetComponent(reqSrc.SourceConnection, new CommandTargetComponent {targetEntity = player});
    23.  
    24.             PostUpdateCommands.DestroyEntity(reqEnt);
    25.         });
    26.     }
    27. }
     
    Last edited: Aug 25, 2020
    Ghosthowl likes this.
  37. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    It is used a lot by DotsSample so it's something we have to keep in a working state. DotsSample is not serializing transforms on child entities though. I'll add making a sample for that to our list, but I can't say when it will be done.
    Did you check in the entity debugger if the transforms on the child are correct?
     
    florianhanke likes this.
  38. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    Thanks, I'll update those
    This should be referencing ghostOwner.NetworkId and the foreach should be
    Entities.WithAll<MovableCubeComponent>().WithNone<CubeInput>().ForEach((Entity ent, ref GhostOwnerComponent ghostOwner) =>

    It is supposed to be player, but there should be a line before doing
    var player = EntityManager.Instantiate(prefab);
     
    Ghosthowl and florianhanke like this.
  39. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    Ah, thanks for the clarifications, I had commented the issues out (since they're not needed for the repro case), so had not looked into them in detail. This line

    RequireSingletonForUpdate<EnableNetCubeGhostReceiveSystemComponent>();
    may reference a missing
    EnableNetCubeGhostReceiveSystemComponent
    .
    Also, I'm not sure if you've seen my post above noting that the markdown headers in the Changelog are broken…?
     
    Last edited: Aug 25, 2020
    Ghosthowl likes this.
  40. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    Yes – the first thing I assumed is that data is not set correctly or missing, but the transform data actually seems fine (see photo).
    Screenshot 2020-08-25 at 22.06.57.png
    I hope I can reproduce the issue in a minimal way.
     
  41. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    Yes, that is only needed if you have multiple scenes in the same project running different logic, we'll remove that from the getting started guide.
    I did, I fixed it in our repo, but that does not fix the html version.
    That rotation does not look like a unit quaternion to me, and non-unit quaternions tend to break transform systems badly
     
    Ghosthowl likes this.
  42. Justin_Larrabee

    Justin_Larrabee

    Joined:
    Apr 24, 2018
    Posts:
    106
    I don't see any mention of DynamicBuffer, is support for replicating it added or pending?
     
  43. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    Sorry – could not widen the inspector enough for the numbers to be completely visible, as it was beachballing even in pause mode. Made it after several tries:
    Screenshot 2020-08-25 at 22.55.50.png
    With the exponents visible, it now looks like a unit quaternion.
     
  44. Justin_Larrabee

    Justin_Larrabee

    Joined:
    Apr 24, 2018
    Posts:
    106
    Also is there any work being done to alleviate the need for ghost collections? It's a very awkward workflow when you have selectively loaded entities. As an example, if I have four factions that have up to thirty units each, but an actual game session only uses two factions and ten units each, how would I avoid loading and converting all 120 entities?
     
  45. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    We are working on it, but it is not far enough along that we can give a target version or date yet.

    What is you main concern with it? Is it memory usage, CPU time, the authoring being difficult with such large number, or something else?
    Runtime conversion (including ConvertToEntity) will likely be deprecated from the netcode package soon, and the sub-scene conversion will need to convert all prefabs in order for you to be able to use them at runtime. So avoiding converting all prefabs does not seem possible.
    At runtime we do need to have a list of all the prefabs you are going to use so we have no plans on removing the ghost collections from the runtime. We have talked about making it possible to extend or even construct the GhostPrefabCollection at runtime instead of through conversion, if we do that you could potentially get the prefabs converted and stored any way you want and assemble them to a collection at runtime based on some dynamic logic.
    To be clear, this is not something we are currently working on or have any concrete plans to work on right now.
     
    bb8_1 and cdm456852 like this.
  46. Occuros

    Occuros

    Joined:
    Sep 4, 2018
    Posts:
    300
    I want to modify (quantization, and some components which should only exist on client/server). Before we just had those checkboxes directly on the prefab, but as we now can define them directly on the components, I didn't manage to get it to work on pre-existing components (like from the physics package or translations etc.)


    I created a class inside a normal .cs file:

    Code (CSharp):
    1. public class NetworkingTestModifiers : IGhostDefaultOverridesModifier
    2. {
    3.     public void Modify(Dictionary<string, GhostAuthoringComponentEditor.GhostComponent> overrides)
    4.     {
    5.      
    6.         overrides["Unity.Physics.PhysicsCollider"].attribute.PrefabType = GhostPrefabType.Server;
    7.         overrides["Unity.Physics.PhysicsDamping"].attribute.PrefabType = GhostPrefabType.Server;
    8.         overrides["Unity.Physics.PhysicsMass"].attribute.PrefabType = GhostPrefabType.Server;
    9.         overrides["Unity.Physics.PhysicsVelocity"].attribute.PrefabType = GhostPrefabType.Server;
    10.         overrides["Unity.Physics.PhysicsCollider"].attribute.PrefabType = GhostPrefabType.Server;
    11.         //just for testing
    12.         overrides["Unity.Transforms.Rotation"].attribute.PrefabType    = GhostPrefabType.Client;
    13.  
    14.     }
    15.     public void ModifyAlwaysIncludedAssembly(HashSet<string> alwaysIncludedAssemblies) { }
    16.     public void ModifyTypeRegistry(TypeRegistry typeRegistry, string netCodeGenAssemblyPath) { }
    17. }
    18.  


    but this seems to have no effect (at least when I update the component list, nothing changes).

    Its probably because I miss the following part of the documentation:

    As well as adding attributes, you can specify rules for components which you do not have source access to by creating an assembly with a name ending with .NetCodeGen


    But I'm a little confused about what that part means.

    Could someone shed some light on how to modify quantization/sending component data in code on predefined components?
     
  47. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    @Occuros Sure – here's how I'm doing it.
    Create an eg. Overrides folder in Assets/Scripts and create an Assembly Definition inside it:
    Screenshot 2020-08-26 at 19.19.59.png
    Then, rename it to Overrides.NetCodeGen (the extension will be asmdef) and add References to NetCode and NetCode.Editor. Then click apply:
    Screenshot 2020-08-26 at 19.20.11.png
    Then, move your .cs file to the folder:
    Screenshot 2020-08-26 at 19.20.26.png
    I'm new to this as well, but I hope that helps.
     
  48. Occuros

    Occuros

    Joined:
    Sep 4, 2018
    Posts:
    300
    Thank you @florianhanke, that works for the rotation changes.

    But for the unity physics part I get a key not found exception:

    Code (CSharp):
    1. overrides["Unity.Physics.PhysicsVelocity"].attribute.PrefabType = GhostPrefabType.Server;
    When I add this, I get the following exception:

    Code (CSharp):
    1. System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
    2.  
    Although I think the string value should be the fully classified name. So one step closer, but I still seem to be missing something.
     
    florianhanke likes this.
  49. florianhanke

    florianhanke

    Joined:
    Jun 8, 2018
    Posts:
    426
    When I tried to reproduce my case described above, I noticed the rotation not being synced correctly. I'll describe the case here, so I can reference it in the bug report.

    I set up the basic Getting Started, but without any interactivity.
    Then, under the SharedData empty with the convert component, I add a parent Cube and a Child Cube:
    Screenshot 2020-08-26 at 19.35.00.png
    The Cube has the Ghost Authoring Component:
    Screenshot 2020-08-26 at 19.35.34.png
    In the scene view the cubes are together:
    Screenshot 2020-08-26 at 19.35.06.png
    I added the asmdef, together with the override, as described above:
    Code (CSharp):
    1. using System.Collections.Generic;
    2.  
    3. using Unity.NetCode.Editor;
    4.  
    5. namespace Networking.Overrides
    6. {
    7.     public class ChildOverrides : IGhostDefaultOverridesModifier
    8.     {
    9.         public void Modify(Dictionary<string, GhostAuthoringComponentEditor.GhostComponent> overrides)
    10.         {
    11.             // Overrides definition for all children to send transforms.
    12.             UnityEngine.Debug.Log("Override definition for all children to send transforms.");
    13.             overrides["Unity.Transforms.Translation"].attribute.SendDataForChildEntity = true;
    14.             overrides["Unity.Transforms.Rotation"].attribute.SendDataForChildEntity    = true;
    15.         }
    16.  
    17.         public void ModifyAlwaysIncludedAssembly(HashSet<string> alwaysIncludedAssemblies) { }
    18.  
    19.         public void ModifyTypeRegistry(TypeRegistry typeRegistry, string netCodeGenAssemblyPath) { }
    20.     }
    21. }
    When I run it, the Child Cube is not rendered, and in the Entity Debugger, the Rotation contains only NaN values:
    Screenshot 2020-08-26 at 19.39.45.png
    When I comment the script where I override SendDataForChildEntity, the Child Cube is rendered correctly, and the Entity Debugger values for the Rotation are correct:
    Screenshot 2020-08-26 at 19.41.31.png

    My expectation was that the synced values and the non-synced values would be identical. Instead, when I sync the child values, the Rotation values are NaN whereas on the server they are (0, 0, 0, 1).

    I'll post the case number here as soon as I have one. Edit: It's Case 1273243.

    A sample like that would be great and I think would certainly help you guys even more than me :)

    Also: It's a great jump from 0.2 to 0.3 in terms of usability :D
     
    Last edited: Aug 26, 2020
    Lukas_Kastern likes this.
  50. TRS6123

    TRS6123

    Joined:
    May 16, 2015
    Posts:
    246
    @Occuros Look at GhostAuthoringComponentEditor. You can see how it registers Translation and Rotation. The path is Packages/Unity NetCode/Editor/GhostAuthoringComponentEditor.