Override rotation of bones and apply custom IK on humanoid character?

I have a humanoid character model, with an animation controller and some basic locomotion animations.

I want to create a script that makes the character crank a lever.

I made an custom IK script to attach the character’s hands to the lever’s handle, so that i can just change the rotation of the lever via script, and the hands will follow automatically and the elbows will move accurately, thanks to the IK script.

However, as Unity doesn’t provide full body IK (and neither do i want to purchase it from the asset store) the hips do not move along with the hands when the lever goes out of reach of the hands.

To solve this i wrote another script ‘BendSpine’ (in LateUpdate) that simply rotates the spine towards the lever’s handle so that the hands can reach them.

But, now all the children of the spine (including the hands) inherit that rotation, and even with the IK active, the hands move away from the lever’s handle.

Any ideas on how we can override the rotation of the spine first, and then we can apply IK to the hands so that whatever the distance of the lever from the character, the hands can always (well, most of the time) reach the handle?

no idea.

You may want to stay in the bounds of unity’s systems to accomplish your goals, else you will sink much time into this small thing, that is my feeling anyway but I Don’t know what your project is. ;D

Specifically, I suggest: adding a layer to the controller with an upper body Avatar Mask. Have animations on that layer for leaning forward, to the left, to the right, etc. Use a blend tree and the strength of that layer to make the motion look dynamic.