Azure Kinect Body Tracking Unity 3D does not work/track body after reloading scene using SceneManager.LoadScene.

2023-01-09T18:18:28.027+00:00

I've gotten the azure body tracking SDK to work. I am making a game with a restart functionality. However when I reload the scene using SceneManager.LoadScene and a button, after reloading, the body tracker ceases to work while the rest of my game is still working

Azure Kinect DK
Azure Kinect DK
A Microsoft developer kit and peripheral device with advanced artificial intelligence sensors for sophisticated computer vision and speech models.
287 questions
{count} votes

1 answer

Sort by: Most helpful
  1. QuantumCache 20,031 Reputation points
    2023-03-10T01:01:46.6366667+00:00

    Hello,

    This issue may be related to the way the Azure Kinect Body Tracking SDK is initialized and shutdown. When the scene is reloaded, the body tracking SDK may not be properly initialized again.

    One possible solution is to create a separate script that handles the initialization and shutdown of the body tracking SDK. This script should be added to a GameObject that persists across scene changes.

    private void Awake()
        {
            // Load the body tracking DLL
            bodyTrackingDllHandle = LoadLibrary(BodyTrackingDllPath);
    
            // Get the function pointers to the body tracking functions
            k4abt_tracker_create_func = GetProcAddress(bodyTrackingDllHandle, "k4abt_tracker_create");
            k4abt_tracker_destroy_func = GetProcAddress(bodyTrackingDllHandle, "k4abt_tracker_destroy");
            k4abt_tracker_enqueue_capture_func = GetProcAddress(bodyTrackingDllHandle, "k4abt_tracker_enqueue_capture");
            k4abt_tracker_pop_result_func = GetProcAddress(bodyTrackingDllHandle, "k4abt_tracker_pop_result");
    
            // Create the body tracking tracker handle
            int calibrationHandle = GetCalibrationHandle();
            k4abt_tracker_create_func(calibrationHandle, IntPtr.Zero, out trackerHandle);
        }