Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

CopyTransformToGameObject out of aligment

Discussion in 'Entity Component System' started by debuggerpls, Mar 13, 2020.

  1. debuggerpls

    debuggerpls

    Joined:
    Dec 1, 2019
    Posts:
    6
    Hello,
    Im using CopyTransformToGameObject for the player, so that camera can follow it. The meshRenderer of the GO is disabled and when Entity is rotated, its Local rotation axis gets out of aligment from the rendered Entity (in Editor). I use this code to rotate the Entity around its axis:
    Code (CSharp):
    1. float3 back = new float3(0f, 0f, -1f);
    2. float3 right = new float3(1f, 0f, 0f);
    3.  
    4. quaternion q = quaternion.EulerXYZ(back * delta * inputAxis.L_Horizontal);
    5. rotation.Value = math.mul(math.normalize(rotation.Value), q);
    6.  
    7. q = quaternion.EulerXYZ(right * delta * inputAxis.L_Vertical);
    8. rotation.Value = math.mul(math.normalize(rotation.Value), q);
    Am I rotating the entity wrong or is there a trick, so that Entity and GameObject Rotation axis keeps in sync?

    Thanks in advance