Search Unity

Bug Limited Hinge axis change via inspector

Discussion in 'Physics for ECS' started by Sab_Rango, May 20, 2021.

  1. Sab_Rango

    Sab_Rango

    Joined:
    Aug 30, 2019
    Posts:
    121
    Case 1337341

    Currently the Limited Hinge axis value manipulation via directly inspector making incorrect arrawhandle directions in the editor mode.
    thebughinge_LI.jpg

    So then I did a little code change in the main EditorUtilities.cs

    Code (CSharp):
    1. .....
    2. ... line --150
    3.  
    4. EditorGUI.BeginChangeCheck();
    5.  
    6.                 // Make rotators
    7.                 quaternion oldRefA = m_RefA;
    8.                 quaternion oldRefB = m_RefB;
    9.  
    10.                 float3 pivotAinW = math.transform(worldFromA, pivotA);
    11.                 m_RefA = Handles.RotationHandle(m_RefA, pivotAinW);
    12.  
    13.  
    14.  
    15.  
    16.  
    17.  
    18.  
    19.  
    20.  
    21.                 ////---------------here mychange---------------------------------
    22.                 if (bquadset)
    23.                 {
    24.                     quaternion temp = new quaternion();
    25.                     Quaternion templegacy = new Quaternion();
    26.  
    27.                     templegacy.eulerAngles = EulerV;
    28.  
    29.                     temp.value.x = templegacy.x;
    30.                     temp.value.y = templegacy.y;
    31.                     temp.value.z = templegacy.z;
    32.                     temp.value.w = templegacy.w;
    33.  
    34.  
    35.  
    36.                     m_RefA = temp;
    37.                     m_RefB = temp;
    38.  
    39.  
    40.                     quaternion dqA = math.mul(m_RefA, math.inverse(oldRefA));
    41.                     quaternion dqB = math.mul(m_RefB, math.inverse(oldRefB));
    42.                     directionAinW = math.mul(dqA, directionAinW);
    43.                     directionBinW = math.mul(dqB, directionBinW);
    44.                     perpendicularAinW = math.mul(dqB, perpendicularAinW);
    45.                     perpendicularBinW = math.mul(dqB, perpendicularBinW);
    46.                     changed = true;
    47.                 }
    48.  
    49.                 ////--------------------mychange------------------------------------------
    50.  
    51.  
    52.  
    53.  
    54.  
    55.  
    56.  
    57.  
    58.  
    59.  
    60.                 float3 pivotBinW;
    61.                 if (lockBtoA)
    62.                 {

    then also changes the target change if statement when my bool is on.

    here the result mysolution.png



    After the manupulation, the arrowhangles directions facing where they supposed to when the value changes via my Euler vector variables.


    In the next updates, I hope the limited hinge joint variables can be changeable via inspector values like in my sample code. Since right now , only RotationHandles in the editor GUI can change the local Axis values properly
     
    steveeHavok likes this.