3Point VR Body Tracking In Unity SteamVR Tutorial

I’m going to write this tutorial differently than I normally do, as my normal strategy is to just paste in my code I spent forever working on into the article and then explain how it works and how to use it. For this one, though I don’t have a final product/draft of my code as a lot of the features of something like body tracking comes down to coder preference. Therefore I am just going to explain my method and leave it up to smart people like you to figure out how to do it.

So above you see my mostly finished product, It’s pretty simple (*cough) but it does the job pretty well.

It basically focuses on four things: The head, torso, arms, and legs.

To start I got the arms working, and to do that I needed a good IK plugin. Now I’m a broke teen that blew all his money on the headset I’m using to make these tutorials so I can’t exactly go and shell out $90 dollars for Final IK. So I did the natural thing and looked at all the free IK assets on the Unity store and none of them had what I wanted. So I just made my own that was ten times better than all of them. Code Here. Then using that I got my arms working.

I noticed that your elbow usually lines up with the side of your hand that your pinky finger is on so I just parented the pole to my hand so that the elbow would always face that direction.

Next, I focused on getting my head and torso working, for the head, I just wrote some code that positioned it in the same place as the HMD with a little offset and set the camera’s close clipping plane a little farther away so that I wouldn’t see the back of my face.

For the torso, I did the same thing but made it so that when the head looked down the torso would push back so you could see it and anything attached to it (ie. spare mags, grenades) and made it so it would only rotate when you looked to the left or right more than a certain angle. I also added some code so that when one of my hands wasn’t reaching the controller the torso would rotate to help it make it there. And finally, there was one last bit of code that rotated the torso so that the closer my head was to the ground the more my torso would rotate back to make it squat.

The legs were especially hard as you have to get them to move in the direction of your movement but when you move backward the legs need to face forward while moving backward. And the feet need to match up with the terrain as you move. Now the way I did this is really complicated but suffice it to say It includes sine waves and keeping track of how far you’ve moved and how fast you’re moving. Though It still needs work, I still need to make the feet rotate to line up with the ground.

And that is the end of this tutorial for now. Now I know I left a lot out so comment below with your questions, If I can answer them I’ll try. Also If you want the code anyway then tell me that too and I might clean it up and improve it so I can give it to you guys. (Note: the first part of the tutorial is up)

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