Greetings,
I have observed the following URLs prior to asking this question:
However, this does not seem to work when the target rotation is of the CCDIK-kind. This is what I have tried so far for a chain that consists of ConfigurableJoints from the hand as the effector, the forearm, upper arm, and to the shoulder as the base where the different joints are not hierarchical but on the same level (but I have also tried hierarchical):
for(int c = 1; c < Segments.Count; c++)
{
Quaternion targetOrientation = Quaternion.FromToRotation(Segments[0].transform.position - Segments[c].transform.position, Target.position - Segments[c].transform.position)
//* Segments[c].transform.rotation
;
//Segments[c].transform.rotation = targetOrientation;
//Segments[c].TheJoint.targetRotation = Quaternion.Inverse(targetOrientation);
Segments[c].TheJoint.SetTargetRotation(targetOrientation * Segments[c].transform.rotation, Segments[c].StartLocalRotation);
//Segments[c].TheJoint.SetTargetRotation(Quaternion.FromToRotation(Segments[0].transform.position - Segments[c].transform.position, Target.position - Segments[c].transform.position), Segments[c].StartRotation);
//Segments[c].TheJoint.SetTargetRotationLocal(Quaternion.FromToRotation(Segments[0].transform.position - Segments[c].transform.position, Target.position - Segments[c].transform.position), Segments[c].StartLocalRotation);
//Segments[c].TheJoint.targetRotation =
//Segments[c].transform.rotation *
//Quaternion.Inverse(Quaternion.FromToRotation(Segments[0].transform.position - Segments[c].transform.position, Target.position - Segments[c].transform.position))
//(Quaternion.FromToRotation(Segments[0].transform.position - Segments[c].transform.position, Target.position - Segments[c].transform.position))
// * Segments[c].transform.localRotation
//* Segments[c].transform.rotation
//* Quaternion.Inverse(Segments[0].transform.localRotation)
;
}
I can almost get it to work, but some angles will always be off, especially for the upper arm (and there are jitters, of course):
I am terrible at maths and rotations and I have tried a few things as you can see, but nothing seems to work to make the segments behave as an IK-chain. However, it does work when I simply set the transform’s rotation to (targetOrientation * transform.rotation) without using ConfigurableJoints, but then I am back to start again;
Please help if you can. It is much appreciated. ;w;
In case you want to see how the ragdoll works (without the IK), you can see it here compared to the Unity’s ragdoll wizard (on the right in a spooky outline):