Search Unity

ECS local vs world confusion.

Discussion in 'Data Oriented Technology Stack' started by Vares, Sep 10, 2019.

  1. Vares

    Vares

    Joined:
    Aug 20, 2017
    Posts:
    2
    Can someone expain to me how am i meant to use LocalToWorld in an ECS system?
    I don't really understand the use of the LocalToWorld transform, I tried to just rotate an entity via its rotation component:
    Code (CSharp):
    1. public void Execute(ref Rotation rotation, [ReadOnly] ref RotationQuaternionComponent rotationQuaternion) {
    2.             rotation.Value = math.mul(rotation.Value, rotationQuaternion.RotationQuaternion);
    3. }
    The result was a rotation that seems to be local to the entity.
    If i do the same for translation, it seems to move globally. This sets location to global (0,10,0):

    Code (CSharp):
    1.  
    2. public void Execute(ref Translation translation, [ReadOnly] ref MovementVectorComponent vector) {
    3.  
    4.             translation.Value = new float3(
    5.                0f,
    6.                 10f,
    7.                 0f);
    8. }
    9.  
    I feel like i am totally misunderstanding something. Why is one global and one local? How do I use LocalToWorld?
    Also it seems that neither rotation nor translation show up in the inspector when i click on the entity from the entity debugger. Is there any way to display them as well?
     
  2. thelebaron

    thelebaron

    Joined:
    Jun 2, 2013
    Posts:
    277