Made my own first IK solver for VR hands

Show-Off

Posted Mar 19, 2020, 10:52 PM UTC

22
nehvaleem•

dude... nails!

2
tmachineorgOP•

Using Alan's great tutorial here: https://www.alanzucconi.com/2017/04/10/robotic-arms/ I was able to build a generic hand rig, and an IK solver, in Unity. Not perfect, but it's going to save a lot of time vs hand-animating dozens of different hand meshes.

Background: Most of the "VR Hands" sold on the asset store are missing the animations needed for the current gen VR headsets (most of them don't have any VR-specific animations, they just have generic gesture anims, which is fair enough). I'm learning the new Unity XR Interaction Toolkit system (write once, deploy to any VR headset), and thought it would be cool to integrate lots of different virtual hands and let players swap in/out any they wanted.

So ... I took Alan's tutorial and:

  1. Built a custom class to detect a "hand" and all the bones + joints (basically does what Unity's "Humanoid" detector does, but specialised for hands)
  2. Took a few pre-rigged hands and tried animating them. For every problem I found, I wrote extra utility scripts. e.g. some artists rig their joints to bend in X axis, others use Z axis, so I needed a button to switch between the two.
  3. Added code to guess where the finger-tips are on each hand (doesnt have a joint normally)
  4. Manually decorated some controllers (Oculus Touch here) with target points for each finger-tip
  5. Ran Alan's simplistic IK solver to move the fingers to the relevant buttons and switches.

The beauty of this is it works well even for non-standard hands, like the alien hand with only 3 fingers. Next step is to add multi-directional joints, so that I can get the thumb doing IK for the joystick and top buttons.

1