Azure Kinect Examples for Unity

Azure Kinect Examples for Unity, v1.17.3 is a set of Azure Kinect (aka ‘Kinect for Azure’, K4A) examples that use several major scripts, grouped in one folder. The package currently contains over thirty five demo scenes. Apart of the Azure Kinect sensor (aka K4A), the K4A-package supports the “classic” Kinect-v2 (aka Kinect for Xbox One) sensor, as well as Intel RealSense D400-series sensors.

The avatar-demo scenes show how to utilize Kinect-controlled avatars in your scenes, gesture demo – how to use discrete and continuous gestures in your projects, fitting room demos – how to overlay or blend the user’s body with virtual models, background removal demo – how to display user silhouettes on virtual background, point cloud demos – how to show the environment or users as meshes in your scene, etc. Short descriptions of all demo-scenes are available in the online documentation.

This package works with Azure Kinect (aka Kinect for Azure, K4A), Kinect-v2 (aka Kinect for Xbox One) and Intel RealSense D400-series sensors. It can be used with all versions of Unity – Free, Plus & Pro.

How to run the demo scenes:
1. (Azure Kinect) Download and install the latest release of Azure-Kinect Sensor SDK. The download link is below. Then open ‘Azure Kinect Viewer’ to check, if the sensor works as expected.
2. (Azure Kinect) Follow the instructions on how to download and install the latest release of Azure-Kinect Body Tracking SDK and its related components. The link is below. Then open ‘Azure Kinect Body Tracking Viewer’ to check, if the body tracker works as expected.
3. (Kinect-v2) Download and install Kinect for Windows SDK 2.0. The download link is below.
4. (RealSense) Download and install RealSense SDK 2.0. The download link is below.
5. (iPhone Pro) For integration with the iPhone’s LiDAR sensor, please look at this tip.
6. Import this package into a new Unity project.
7. Open ‘File / Build settings’ and switch to ‘PC, Mac & Linux Standalone’, Target platform: ‘Windows’ & Architecture: ‘x86_64’, and in ‘Player settings’ make sure the ‘Scripting backend’ is set to ‘Mono’.
8. Make sure that ‘Direct3D11’ is the first option in the ‘Auto Graphics API for Windows’-list setting, in ‘Player Settings / Other Settings / Rendering’.
9. Open and run a demo scene of your choice from a subfolder of the ‘AzureKinectExamples/KinectDemos’-folder. Short descriptions of all demo-scenes are available in the online documentation.

* The latest Azure Kinect Sensor SDK (v1.4.1) can be found here.
* The latest Azure Kinect Body Tracking SDK (v1.1.2) can be found here.
* Older releases of Azure Kinect Body Tracking SDK can be found here.
* Instructions how to install the body tracking SDK can be found here.

* Kinect for Windows SDK 2.0 can be found here.
* RealSense SDK 2.0 can be found here.

* The K4A-asset may be purchased and downloaded in the Unity Asset store. All updates are and will be available to all customers, free of any charge.
* If you’d like to try the free version of the K4A-asset, you can find it here.
* If you’d like to utilize the Intel RealSense sensor with Cubemos body tracking, please look at this tip.
* If you’d like to utilize the LiDAR sensor on your iPhone-Pro or iPad-Pro as a depth sensor, please look at this tip.

Free for education:
The package is free for academic use. If you are a student, lecturer or university researcher, please e-mail me to get a free copy of the K4A-asset directly from me.

One request:
Please don’t share this package or its demo scenes in source form with others, or as part of public repositories, without my explicit consent.

* The basic documentation is in the Readme-pdf file, in the package.
* The K4A-asset online documentation is available here and as pdf.
* Many K4A-package tips, tricks and examples are available here.

* If you get errors like ‘Can’t create body tracker for Kinect4AzureInterface0!‘, please follow these tips:

  • Check, if you have installed the Body Tracking SDK v1.1.2 into ‘C:\Program Files\Azure Kinect Body Tracking SDK’-folder.
  • Start the ‘Azure Kinect Body Tracking Viewer’, and check if it works as expected.
  • Please note, the ‘Azure Kinect Body Tracking Viewer’ by default uses DirectML-processing mode, while the K4A-asset by default uses CUDA-processing mode (for performance reasons).
  • If you have NVidia GPU and prefer to stay with the CUDA processing mode for body tracking, please make sure you have installed the latest NVidia driver. See this link for more information. To make sure the CUDA processing more works on your machine, please open the command prompt (cmd), type ‘cd C:\Program Files\Azure Kinect Body Tracking SDK\tools’, and then run ‘k4abt_simple_3d_viewer CUDA’. This will start the ‘Azure Kinect Body Tracking Viewer’ with CUDA-processing mode.
  • Otherwise, if CUDA doesn’t work or you prefer to use DirectML (as ‘Azure Kinect Body Tracking Viewer’ does) in the K4A-asset too, please open the ‘Kinect4AzureInterface.cs’-script in ‘AzureKinectExamples/KinectScripts/Interfaces’-folder, find this line: ‘public k4abt_tracker_processing_mode_t bodyTrackingProcessingMode = k4abt_tracker_processing_mode_t.K4ABT_TRACKER_PROCESSING_MODE_GPU_CUDA;‘, and replace it with ‘private k4abt_tracker_processing_mode_t bodyTrackingProcessingMode = k4abt_tracker_processing_mode_t.K4ABT_TRACKER_PROCESSING_MODE_GPU_DIRECTML;‘. Then save the script, return to Unity and try to run the demo scene again.

* If the scene works in Unity editor, but doesn’t work in the build, please check if the ‘Architecture’ in Build settings is ‘x86_64’, and the ‘Scripting backend’ in Player settings is set to ‘Mono’.
* If you can’t upgrade the K4A-package in your project to the latest release, please go to ‘C:/Users/{user-name}/AppData/Roaming/Unity/Asset Store-5.x’ on Windows or ‘/Users/{user-name}/Library/Unity/Asset Store-5.x’ on Mac, find and delete the currently downloaded package, and then try again to download and import it.
* If Unity editor freezes or crashes at the scene start, please make sure the path where the Unity project resides does not contain any non-English characters.
* If you get syntax errors in the console like “The type or namespace name ‘UI’ does not exist…”, please open the Package manager (menu Window / Package Manager) and install the ‘Unity UI’ package. The UI elements are extensively used in the K4A-asset demo scenes.
* If you get “‘KinectInterop.DepthSensorPlatform’ does not contain a definition for ‘DummyK2′” in the console, please delete ‘DummyK2Interface.cs’ from the KinectScripts/Interfaces-folder. This dummy interface is replaced now with DummyK4AInterface.cs.
* If the Azure Kinect sensor cannot be started, because StartCameras()-method fails, please check again #6 in ‘How to run the demo scenes‘-section above.
* If you get a ‘Can’t create the body tracker’-error message, please check again #2 in ‘How to run the demo scenes‘-section above. Check also, if the Body Tracking SDK is installed in ‘C:\Program Files\Azure Kinect Body Tracking SDK’-folder.
* If the body tracking stops working at run-time or the Unity editor crashes without notice, update to the latest version of the Body tracking SDK. This is a known bug in BT SDK v0.9.0.
* Regarding RealSense: If you’d like to try its integration with Cubemos body tracking SDK, please look at this tip.
* If there are errors like ‘Shader error in [System 1]…’, while importing the K4A-asset, please note this is not really an error, but shader issues due to missing HDRP & VFX packages. You only need these packages for the Point-cloud demo. All other scenes should be started without any issues.
* If there are compilation errors in the console, or the demo scenes remain in ‘Waiting for users’-state, make sure you have installed the respective sensor SDKs and the other needed components. Please also check, if the sensor is connected.

What’s New in Version 1.17.x:
1. Added ‘Joint position smoothing’ & ‘Joint velocity smoothing’-settings to KM, to provide smoothing of
joint positions and joint velocity calculations (thanks to matmat_35 & Edgaras Artemciukas).
2. Added support of IL2CPP scripting backend to the Azure Kinect sensor interface (thanks to Jelvand).
3. Fixed the functionality of ‘Show Allowed Users Only’-setting of KM (thanks to dbb0000).
4. Fixed the offset node to apply rotation in AvatarController (thanks to Martin Cvengros).
5. Fixed the ColorImageJointOverlayer-component to work with ForegroundRenderer in
BackgroundRemovalDemo5-scene (thanks to Mateusz Pomaski).
6. (1.17.1) Added support to Azure Kinect Body Tracking SDK v1.1.1.
7. (1.17.1) Added sample to display blurred color-camera background (thanks to Edgaras Artemciukas).
8. (1.17.1) Added sample to play multiple sequential recordings (thanks to Lasse Munk).
9. (1.17.2) Fixed the K4A-plugin, to utilize Azure Kinect BT SDK v1.1.1
10. (1.17.2) Added ‘Save recording’-option to the device streaming modes, to save the live sensor data to recording-file (thanks to Mikhail Slobiskiy).
11. (1.17.3) Fixed the K4A-plugin, to utilize Azure Kinect BT SDK v1.1.2
12. (1.17.3) Fixed sensor-relative-position issue, when user bodies get merged across multiple sensors (thanks to 남대현).

Videos worth more than 1000 words:
Here is a holographic setup, created by i-mmersive GmbH, with Unity 2019.1f2, Azure Kinect sensor and “Azure Kinect Examples for Unity”:


167 thoughts on “Azure Kinect Examples for Unity

  1. Hi Rumen, Firstly, I’d like to say that this package is a great tool.
    I’m working on an Unity project using Azure Kinect Examples for Unity for couple of months. It is fine all the time.
    Windows forced updating my system yesterday. After that update finish my project can’t run normally. I had tried some of examples of Azure Kinect Examples for Unity, running the BackgroundRemovalDemo1 scene was showing a small window with title “Unity Editor – Unity 2019.3.3f1_7…” and was terminated immediately. While running BackgroundRemovalDemo2 was everything fine. I found that if I set the parameter of “GetBodyFrames” of Kinect Manager Component to “none” it will be fine, otherwise, it failed to run.
    How do I solve this problem?

    • Hi,

      Obviously there is a problem with the Body Tracking SDK. Please run some of the problematic scenes in the Editor (I suppose the 1st avatar demo will be problematic, as well), then close Unity editor, and e-mail me the Editor’s log file, so I can take a closer look. Here you can see where to find Unity log-files:

  2. Hi Rumen,
    Color camera fps dosen’t look like 30fps.
    But It works perfectly in Azure Kinect Viewer.
    How can I fix it?

    • Hi, I’m not sure what you mean by “fps doesn’t look like 30fps”. Please e-mail me some video clip that shows the issue, the current settings of the KinectManager-component in the scene, and the version of the K4A-asset you are using.

  3. Hi Rumen!

    I have a problem with a Sensor data parameter in Kinect manager: “Get Pose Frames”. By default it has “None” in your plug-in, but I need to have it in “Raw Pose Data” in my project.

    When I use the Kinect4Azure sensor with this parameter set to something other than “None”, both body tracking and application performance drops considerably (it works at 8 fps).

    Do you know why this happens with Kinect Azure? With kinect v2 this problem does not occur to me, since my project must have support to use either of the two sensors.


    OS: Windows 10
    K4Aasset: v1.16

    • Hi. Yes, you are right. This setting (when not None) tries to estimate the sensor’s pose, i.e. its position and rotation. In case of Azure Kinect it determines the height of the sensor above the ground and the sensor rotation around the X & Z axes. This involves some complex computations on the GPU & CPU side, and this causes the performance issues. But usually Azure Kinect is static and its pose needs to be determined only once – after the sensor gets installed. In this regard, please see this tip: , as well as the next one, if you intend to use multiple sensors in your scenes.

      • Thanks! I ended up using the “EnablePoseStream(true/false)” flag to activate and deactivate the imu frames in time for a few seconds, and thus get the position and rotation of the sensor without problems

  4. Hi, I am looking for a help for the following scenario :

    My scenario is I need to capture a color image with Azure Kinect DK and that image has to be downloaded as a PNG or JPG format on my pc using Unity. Can you please share a few references for this scenario implementation.

    • Hi, this should be pretty straight forward. You would need something like this in your script:

      Texture2D texColorImage = (Texture2D)KinectManager.Instance.GetColorImageTex(0);
      byte[] btColorImage = texColorImage.EncodeToPNG();
      System.IO.File.WriteAllBytes("ColorImage.png", btColorImage);

      Please don’t forget to set ‘Get color frames’-setting of the KinectManager-component in the scene to ‘Color texture’, too.

  5. Hi, I’m an Azure Kinect user and I bought your asset and I’m using it for my Unity project.

    I’m curious about the functions of K2’s ColorDepthShader.
    I want to image transform the Depth map to color map(I want 16:9 resolution). ColorDepthShaderK2 seems to function, but can’t it be used in Azure Kinect?

    It would be nice if you could tell me how to use this function in Azure Kinect.

    • Hi, please look at the BackgroundRemovalDemo1-scene and its BackgroundRemoval-game object (and the respective BackgroundRemovalManager & BackgroundRemovalByBodyBounds-components).

  6. Hi Rumen, Great tool!!!

    I am using the network demo. I can use it on Quest 2 and deploy it on Quest2. When I build it for Hololens 2, Editor play mode works fine. But when I deploy it to a real device, error message shows as “Timeout waiting for net-dst”. The server side successfully connects client’s Control Server, ColorServer, and DepthServer. The Editor simulation would have 4 connections on the server. The device deployment only has 3. I think the missing connection is TColorServer.

    Is there anything I can do to dig out the problem?

  7. Hi Rumen, Great Tool package.

    I had a problem with the network demo. I posted a question. It seems that it did not go through. If it did, please delete one of the duplicated posts.

    I used the network demo and deploy it on real device. The deployment on Quest 2 works like a charm.

    I tried it with MRTK on Hololens. In Editor play mode, everything works fine. When I try it on a real Hololens 2 device, I get a “Timeout Waiting for net-dst”. Server side log shows that the Hololens 2 connects ControlServer, ColorServer and DepthServer successfully. I think TColorServer is missing when I compare with Editor play mode log.

    Is that something you have met before?
    What’s next step if I want to find out the real problem?

    • Hi Chao, no I don’t have any experience connecting HoloLens (or HL2) to the KinectNetServer. After you run the Please try to find the Unity log file on the HoloLens, as well as the log-file on the KinectNetServer machine, and e-mail them both over to me, so I can take a closer look at what happens under the hood.

  8. Hi Rumen,

    Can you advice what Unity editor ver would you suggest to do the demo?

    Even tho the free package was written in 2019.1.01f1, I couldnt run it well, got a full black screen on the game scene. Seems to works fine with 2020 but it prompted me if i want to do some pipeline render fix.

  9. Hi Rumen! I’m a MA Computational Arts Student and I was hoping to use your SDK for K4A to Unity to do some testing for a marked project. Would this be ok? Best wishes, Elliot

  10. Pingback: ⭐️⭐️⭐️⭐️⭐️ Azure Kinect Examples for Unity - Published By RF Solutions -

  11. Hi Rumen, with Azure Kinect I often have the problem that the body flips when looking at someone on the ground similar to what is described here Kalman Filtering only helps so much.. any advice how to filter out this flipping? Maybe use another network on top that can tell me which direction the user is facing ( I have rgb , ir and depth)? or only update the model’s nodes when certain joints are tracked? I noticed the flipping is worse when the face is not visible, but it still happens quite a lot even when the face is visible.

    • Hi Marc, could you please e-mail me and (if possible) provide me some video or recording that depicts the problem or helps me reproduce it?

  12. Hi Rumen!
    I have a problem with building:

    In my project, the scene & Kinect Device works fine in Unity Editor, but doesn’t work in the build, the lights of the Device never turned on when the build active. I’ve check my settings: the ‘Architecture’ in Build settings doesn’t have the option named ‘x86_64’, only ‘Intel 64bits’ & ‘Intel 32 bits’, and the ‘Scripting backend’ in Player settings is already set to ‘Mono’ correctly, both of the ‘Architecture’ settings don’t work.

    How do I solve this problem?

    My Environment:
    · Unity Editor 2021.2.0f1c1
    · Kinect 2.0

      • Hi Rumen, thanks for reply!

        After reading the tips behind, I realized that I disable 2 whloe objects with RS & K4A interface in my object with ‘KinectMannager.cs’, rather than set them to ‘Disabled’ in ‘Device Streaming Mode’ (I thought it’s safer if I’m using only K2 LOL).
        Then I build it, and it worked! the K2 Device light up and the function running correctly.

        But I have another try: disabled RS & K4A object again and rebuild it, the weird thing is it worked as well. I’m pretty sure I reboot the project couple of times yesterday, not sure if I should reboot my PC back then. The building log never shows any error since yesterday.

        Anyway, my issue is solved weirdly, just feed it back to you, hope it could helps others, thanks again!

  13. Hey Rumen, I wanted to ask if it was possible to make the networking scenes work when building it for a WebGL Platform? If so where can i start looking into it, i’m not that well versed with networking so any starting hints/tips would be appreciated

  14. Hey Rumen,

    I wanted to ask for your help with something. I am trying to activate the game object containing all the Azure Kinect controller stuff during runtime instead of on Awake.
    I am doing this by setting the gameobject to active when a condition is met.

    However, when I do that, unity freezes for roughly 5-10 seconds as the game object activates and then works as expected.

    Do you know of any way we can achieve activating the gameobject during runtime without the lag/freezing?

    Any help you can provide would be greatly appreciated!

    • Hi, I think this is because of loading libraries (both Azure SDK’s and Body Tracking SDK’s), initializing the environment and starting the sensor. If you leave the object with KinectManager to be initialized on Awake, and then call its StopDepthSensors() and StartDepthSensors() methods from your script, when needed, this may improve the user experience.

  15. Hi Rumen,

    I am trying to use the azure kinect senor sideways, I have followed your instructions from “How to set up sensor’s position and rotation in the scene”. The only thing that I would also need is the ability to rotate the colour and depth images by 90 degrees without actually rotating the screen, e.g. by setting up a scene to be 9:16 or 1080×1920.

    With the current setup, it is really difficult to set up UI and other overlaying elements. Furthermore, if we rotate the screen without rotating it in the windows settings, makes the mouse controls very difficult to operate.


Leave a Reply