How To Use Custom Hands With SteamVR’s Skeletal System In Unity

I’ve actually been looking forward to making tutorial about this for a long time, the reason it has been so long in the making is that my previous HMD was a Windows MR headset and didn’t support the steamVR skeleton. So I did the logical thing and bought an HTC Vive for the sole purpose of making a few tutorials. Anyway, here is the demo of my badly modeled hand working in spite of my programmer art:

[Note from future me]: Once you’re done with this tutorial I have one on changing the default pose editor hand using the prefab you make in this one.

The first step in setting up a custom hand is to have a custom hand. So Let’s do that first. For the skeletal system to work your hand model’s skeleton must match one of the two predefined skeletons provided by the SteamVR plugin. To design my hand model I first imported one of the said predefined skeletons from my steam files (should be found in C:\Program Files (x86)\Steam\steamapps\common\SteamVR\resources\skeletons) into Blender 2.8. I then created a mesh around the skeleton and then parented it (with auto weights) to the skeleton. I’m sure a talented 3D artist could do in a different way but that’s not my area of expertise. Also, make sure the 6 helper bones have no influence over your model. (The helper bones are the root and any that end in aux.) Now all that’s left to do is to export your model as an Fbx file to your unity project.

Once in your unity project, we first need check to make sure that blender didn’t add any extra bones to your model when you exported. Any extra bones will cause it to fail. To do this first create an empty game object and then add your model as a child, this is so we can mess with the offset later. Next right click your model in the inspector and click unpack prefab so we can mess around with our skeleton. Next, go and delete all the extra bones if any, for me blender added an extra bone to the end of every chain. If you get an index array out of bounds exception or similar, this means you have extra bones. Next, reorder the root bones of each finger so in the inspector they are in the order: Thumb, Index, Middle, Ring, Pinky. If they aren’t in the right order you get something like this:

Now all that’s left is to add a SteamVR_Skeleton_Behavior script to your no longer empty game object and set the variables. Set the Skeleton action and Input source to the hand you built the model for and the root to the bone labeled root. If you are moving around your [CameraRig] GameObject you will want to set the origin to the [CameraRig]. Now all that’s left is to test it and to create a prefab if it works. If your model is following your actions but is not in the right position you can fix that by moving around your container object until it’s in the right place.

One more thing then we are done, (meta alert) after I published this article I used the same steps to create a left hand, I imported the left-hand skeleton into blender, inverted my mesh and applied transforms. When I imported it into unity and set all the right setting it worked. But! When I started trying to use it with poses it turned into spaghetti. The right hand was still working but the left refused to work while blending to a pose. I opened the SteamVR default prefab to see how it works and found nothing until I realized that the parent of the Root bone was flipped on the x-axis. So took the prefab that was working and I did the same thing. Then I had flipped spaghetti. After some time smashing the wall with my head I found this setting at the very bottom of the Skeleton script.

I set the same setting on my hand and it worked without complaining. Don’t be me and take 4 hours to figure that out.

That’s all I’m covering in this one but soon I’m going to write another on actually using the skeleton system, so keep an eye out for that one. Also once again click here to find out how to use your custom hands in the pose editor. If you have any other questions or problems don’t hesitate to comment down below and I’ll try to answer intelligently.

Liked it? Take a second to support WireWhiz on Patreon!
Become a patron at Patreon!