Search Unity

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