Search Unity

Non-Forward axis LookAt (IK)

Discussion in 'Scripting' started by SinisterMephisto, Dec 21, 2014.

  1. SinisterMephisto

    SinisterMephisto

    Joined:
    Feb 18, 2011
    Posts:
    179
    Hi,
    I am having a bit of a road block here
    I am trying to make my hip joint look at the next foot target but the rest pose of the hip transform has the x facing down, z to the side and y back.
    Using the regular look at does some funny stuff (See image)

    Basically I want the x axis to point to the next target

    I tried

    Code (csharp):
    1.  
    2. Vector3 a = foot.position - hip.position;
    3. Vector3 b = target.position - hip.position;
    4.  
    5. //Tried with direct and normalized values
    6. //Setting to the result and multiplying the current rotation to the result
    7. //and Inverse of the result
    8. //localRotation ...
    9. hip.rotation *= Quaternion.fromToRotation(a,b);
    10.  
     

    Attached Files: