Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

CopyTransformToGameObject out of aligment

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

  1. debuggerpls


    Dec 1, 2019
    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);
    4. quaternion q = quaternion.EulerXYZ(back * delta * inputAxis.L_Horizontal);
    5. rotation.Value = math.mul(math.normalize(rotation.Value), q);
    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