Peter Daukintis, Microsoft Technical Evangelist has been on a Kinect Unity roll recently. Today he answers a question that I've also seen asked often, custom gestures in Unity3D
Here's some of the other posts from Peter we've highlighted recently;
- Two for Kinect 4 Windows v2 and Unity 3D
- Kinect 4 Windows V2 & openFrameworks
- Saluting the Visual Gesture Builder - Details and example code
- Kinect for Windows v2 Face Tracking Managed and Native
I have received a few questions recently about detecting Kinect custom gestures in Unity 3D and it seems that there are a few issues with getting this up and running. I have previously posted about Kinect Custom Gestures and also using ‘built-in’ gestures from the Kinect 4 Windows SDK inside Unity so it makes sense to complete the loop here. I’ll run through my experience. A few things to set up straight off the bat:
I created a new Unity project and selected to install the Visual Studio 2013 Tools Unity Package (not required but I like to debug using Visual Studio)
I imported some Unity Kinect custom packages: Assets > Import Package > Custom Package and then navigated to the Kinect Unity Package location on my local disk. (the Kinect unity package can be downloaded here http://go.microsoft.com/fwlink/?LinkID=513177). Add both the Kinect and Kinect.VisualGestureBuilder packages.
Creating the Scene
As before, in this previous post I created an empty game object and also a new c# script and added the following code to detect the Kinect sensor, pull the body data, exposing it to other scripts and also to retrieve the body tracking ID which will be required to identify the body on which we are detecting the gestures. To keep things simple I assumed only one tracked body and as always remember this is intended as a sample so I may not be as careful with cleaning up event handlers, etc.
Find the sample project here.
Other useful resources:
Another working sample – https://github.com/carmines/workshop/blob/dev/Unity/VGBSample.unitypackage
Project Information URL: http://peted.azurewebsites.net/kinect-4-windows-v2-custom-gestures-in-unity/
Project Source URL: http://1drv.ms/1uKAxK2