Search Unity

Parent, LocalToParent, LocalToWorld and Translation problem...

Discussion in 'Entity Component System' started by threedots1, Nov 23, 2019.

  1. threedots1

    threedots1

    Joined:
    Oct 9, 2014
    Posts:
    88
    It looks like I'm still getting the same problems I had prior to 0.2.0.

    Two problems:
    1.
    If I have an Entity that only has a LocalToWorld component, and add and set its Parent like so:
    Code (CSharp):
    1. CommandBuffer.AddComponent(index, entity, new Parent {Value = newParent});
    2. CommandBuffer.AddComponent<LocalToParent>(index, entity);
    The entity now has a parent, but its LocalToWorld component is reset to 0,0,0. My assumption would be that the entity would retain its current LocalToWorld, but LTW and LTP are now zeroed out so the Entity teleports to origin upon assigning a Parent.

    2.
    If I modify the Parent of an Entity its current Parent is automatically copied to PreviousParent as expected.
    However I get the following error every single time:
    I can get around it by increasing the size of the hashmap for UniqueParents in Unitys code, but obviously that keeps getting overwritten and I don't want to fork it to fix this.

    Is it because I'm doing it wrong? How am I supposed to do this?
     
  2. Slowin

    Slowin

    Joined:
    Mar 6, 2015
    Posts:
    62
    I have the same problem. On adding LocalToParent using CommandBuffer, the rotation is suddenly changed. The parenting itself works though.

    Anything we can do here?
     
  3. SubdivisionCG

    SubdivisionCG

    Joined:
    May 9, 2020
    Posts:
    15
    Does anybody have an answer to this?

    When parenting my entities using a command buffer, they jump to a different position. The parent-child relationship works, but I obviously don't want them to jump. I want them to keep their current world position (and rotation) when they get parented. How is this handled in ECS?