Three things:
-
Either your bones are not aligned to each other with respect to at least two axis and these axis in relation to the world axis. Say, all green (Y) should be in the +Y of world axis, and Z, while they have different Z due to angles they are bent.
-
You have resized the bones not using the bone tools.
-
Your bones are not “clean” or that their animation controllers need to be reset to something in the form of a brand new one.
Your swivel angle regardless of target therefore causes these to flip.
There are also other factors like preplaced constraints or that the IK solver is linked to another object that may have “broken” transform.
Solutions:
-
Zero out all weights of each bone’s controller in the motion panel. Then assign new respective controllers to each track (Rotation and Position both). Freeze your new transforms.
-
Reset transforms on all your helpers or other stuff linked to the bones or IK before attaching. Freeze them also. Establish hierarchy then freeze transforms before adding constraints.
-
Create new set of bones, and this time make sure everything is “clean”.
Ultimately, errors of this type comes from stuff not being “compatible”. Say Preferred rotation axis settings, etc.
Sometimes it’s just something that requires a lot of tweaking to fix that setting up a new rig is so much easier.
Regardless, I’ve met these problems and could say with honesty that I’m not completely knowledgeable of such errors and why they happen even if I did things correctly and “by the book”.