Search Unity

[FIXED][TransformSystem][Preview11] Wrong positions with parenting

Discussion in 'Entity Component System' started by dzamani, Aug 23, 2018.

  1. dzamani

    dzamani

    Joined:
    Feb 25, 2014
    Posts:
    122
    Hi,

    I will start with saying that I know the package is not ready and it's still an very experimental / not stable thing.

    So, trying this new update I changed the code inside my project from TransformParent to Attach component. The logic was nearly the same so I thought it should work, it did not.
    I triple checked and saw nothing unusual in creating the entities and their positions and then I made a test project to see if there really was an issue.

    It seems like there is one, while you will have no problem parenting 3 objects like a chain, put another one and it fail. In this test project you will see 4 cubes on the left which are what we expect and then 4 other ones with the wrong positions.

    To be exact it's like this: root > e1 > e2 > e3
    While root, e1 and e3 are "correct" the localToWorld matrix of e2 isn't.

    It may be some issue that's already fixed but in the meantime if anyone else tumble upon this. know that it's an issue (if it's by design I do want to know how to fix this problem of mine).

    Thanks!
     

    Attached Files:

  2. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,775
    Any chance you can use anything else than rar? Who is using this format anyway?

    Entities don't have any sense of parenting. Is just your way you parent them, if you like. Then correct way of multiplying transform matrices if applicable.
     
  3. dzamani

    dzamani

    Joined:
    Feb 25, 2014
    Posts:
    122
    Sure, here is the zip file (FYI .rar is still used since Winrar is one of the most known tool and .rar is his default compression type).

    I know Entities do not have any sense of parenting but Attach, Attached, Parent and TransformSystem do.
    In the previous version of the ECS package I used TranformParent.
    Now what I'm saying is that basically the same code from preview 8 to preview 10 broke and that this is the issue I'm reporting.
    TransformSystem does the matrices multiplications by itself.
     

    Attached Files:

    Last edited: Aug 23, 2018
  4. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,775
    Ah ok. This is new to me then.

    I haven't seen rar as major format for years, across international companies. Is that North American thingy?
     
  5. Fido789

    Fido789

    Joined:
    Feb 26, 2013
    Posts:
    343
    There is a preview.11 on staging server, you can try it against this version.
     
  6. dzamani

    dzamani

    Joined:
    Feb 25, 2014
    Posts:
    122
    It's still there.
     
  7. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,775
    Can you revert to known stable version for time being? I am sure Unity team will pick this post on the way.
     
  8. dzamani

    dzamani

    Joined:
    Feb 25, 2014
    Posts:
    122
    I'm not really looking into reverting back to previous version of ECS, I can work on some other things while I wait for this to be fixed. It's more for the purpose of reporting an issue than trying to find a solution.
     
  9. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,775
    Thats completely fine, only thing is, you may get surprised, when thing change back and forward.
    But reporting is mostly valid indeed.
     
  10. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
  11. dzamani

    dzamani

    Joined:
    Feb 25, 2014
    Posts:
    122
    Here is the code inside the Test project (SO is just a scriptable object with a MeshInstanceRenderer):

    Code (CSharp):
    1.  
    2. protected override void OnCreateManager(int capacity)
    3. {
    4.     base.OnCreateManager(capacity);
    5.     EntityManager manager = EntityManager;
    6.     Entity root = manager.CreateEntity(typeof(Position), typeof(Rotation));
    7.     Entity e1 = manager.CreateEntity(typeof(Position));
    8.     Entity e2 = manager.CreateEntity(typeof(Position));
    9.     Entity e3 = manager.CreateEntity(typeof(Position));
    10.     //Entity e4 = manager.CreateEntity(typeof(Position));
    11.     //Entity e5 = manager.CreateEntity(typeof(Position));
    12.  
    13.     Entity attach1 = manager.CreateEntity(typeof(Attach));
    14.     Entity attach2 = manager.CreateEntity(typeof(Attach));
    15.     Entity attach3 = manager.CreateEntity(typeof(Attach));
    16.     //Entity attach4 = manager.CreateEntity(typeof(Attach));
    17.     //Entity attach5 = manager.CreateEntity(typeof(Attach));
    18.  
    19.     manager.SetComponentData(root, new Position() { Value = new float3(0, 1, 0) });
    20.     manager.SetComponentData(root, new Rotation() { Value = quaternion.identity });
    21.     manager.SetComponentData(e1, new Position() { Value = new float3(0, 2, 0) });
    22.     manager.SetComponentData(e2, new Position() { Value = new float3(0, 2, 0) });
    23.     manager.SetComponentData(e3, new Position() { Value = new float3(0, 2, 0) });
    24.     //manager.SetComponentData(e4, new Position() { Value = new float3(4, 0, 0) });
    25.     //manager.SetComponentData(e5, new Position() { Value = new float3(1, 0, 0) });
    26.  
    27.     manager.SetComponentData(attach1, new Attach() { Parent = root, Child = e1 });
    28.     manager.SetComponentData(attach2, new Attach() { Parent = e1, Child = e2 });
    29.     manager.SetComponentData(attach3, new Attach() { Parent = e2, Child = e3 });
    30.     //manager.SetComponentData(attach4, new Attach() { Parent = e3, Child = e4 });
    31.     //manager.SetComponentData(attach5, new Attach() { Parent = e3, Child = e5 });
    32.  
    33.     SO s = Resources.LoadAll<SO>("")[0];
    34.     MeshInstanceRenderer instanceRenderer = new MeshInstanceRenderer()
    35.     {
    36.         mesh = s.MeshInstanceRenderer.mesh,
    37.         material = s.MeshInstanceRenderer.material
    38.     };
    39.     manager.AddSharedComponentData(root, instanceRenderer);
    40.     manager.AddSharedComponentData(e1, instanceRenderer);
    41.     manager.AddSharedComponentData(e2, instanceRenderer);
    42.     manager.AddSharedComponentData(e3, instanceRenderer);
    43.     //manager.AddSharedComponentData(e4, instanceRenderer);
    44.     //manager.AddSharedComponentData(e5, instanceRenderer);
    45. }
    46.  
    47.  
     
    Deleted User likes this.
  12. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,685
    Yeah I tested it, it works only on one hierarchy level
     
  13. mike_acton

    mike_acton

    Unity Technologies

    Joined:
    Nov 21, 2017
    Posts:
    110
    Yes. There was an issue. Will be resolved in newer versions.
     
    Soaryn and dzamani like this.
  14. dzamani

    dzamani

    Joined:
    Feb 25, 2014
    Posts:
    122
    This is fixed in Preview 12.
    Thanks!