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

Question ECS Rotation Contradicting Physics

Discussion in 'Physics for ECS' started by LayZ1307, Jul 6, 2023.

  1. LayZ1307

    LayZ1307

    Joined:
    Aug 14, 2021
    Posts:
    16
    When I rotate like this in ecs using ecs physics my object goes through the floor/collider.
    I have it moving forwards and want to rotate it to change the direction of its forwards movement and this fails.

    Code (CSharp):
    1.     if (Input.GetKey(KeyCode.A))
    2.             {
    3.                 Quaternion tempQuat = new Quaternion(currRot.Value.value.x, currRot.Value.value.y, currRot.Value.value.z, currRot.Value.value.w);
    4.                 //currRot.Value = tempQuat;
    5.                 currRot.Value = math.mul(tempQuat, quaternion.RotateY(math.radians(3 * Time.DeltaTime)));
    6.             }
    7.             else if (Input.GetKey(KeyCode.D))
    8.             {
    9.                 Quaternion tempQuat = new Quaternion(currRot.Value.value.x, currRot.Value.value.y, currRot.Value.value.z, currRot.Value.value.w);
    10.                 //currRot.Value = tempQuat;
    11.                 currRot.Value = math.mul(tempQuat, quaternion.RotateY(math.radians(3 * Time.DeltaTime)));
    12.             }
     
    Last edited: Jul 7, 2023
  2. PolarTron

    PolarTron

    Joined:
    Jun 21, 2013
    Posts:
    87