Quaternion FromToRotation confusion

When i use Quaternion.FromToRotation at certain rotation my object starts slowly spinning for some reason.

bones[i].rotation = Quaternion.FromToRotation(Vector3.up, bones[i + 1].position - bones[i].position) * Quaternion.Inverse(bone_start_rot[i]);

I looks like some kind of crap like gimbal lock or idk what but i know that quaternions don’t suffer from that, yet at some rotation it just starts randomly spinning. I could post the whole code but it is very long and really hard to understand out of context. Did anyone encounter such problem?
I can remove " * Quaternion.Inverse(bone_start_rot*); "* at the end but that doesn’t change anything so the problem is clearly in FromToRotation.

If this term:

bones[i + 1].position - bones*.position*
is in any way different from Vector3.up you are producing some kind of rotation.
If setting this rotation controls the relationship between the positions of the two above bones, it’s just going to keep feeding back into itself.
Keep in mind floating point only has a few decimals of precision when used in a matrix context.

1 Like