Tracking multiple skeletons

Hi,

So I’ve messed around with all the tutorials etc etc. Right now I have a scene where it tracks and maps my model(based on the second tutorial). However, I would like to track multiple skeletons at once and have model 2 activate when the second player walks into the screen(and maybe does a gesture).

Problem is, I can’t seem to find where to start or which functions to use… Any help/direction for me to go is highly appreciated. I know you can see the number of users etc but I have no idea how to modify the script from the second tutorial to even get close to what i’m trying.

Greetz,

Patrick

Hi Patrick,

You can try the following simple solution and use RiggedAvatar.cs from the RiggedModel scene as reference:

  1. Comment/delete the Update method
  2. Make the ProcessSkeleton method public.
  3. Create a new script named SkeletonController, drag-and-drop it to an Empty Object. The content should be as follows:
using nuitrack;
using UnityEngine;

public class SkeletonController : MonoBehaviour {

    [SerializeField] RiggedAvatar[] riggedAvatars;

    private void OnEnable()
    {
        NuitrackManager.SkeletonTracker.OnSkeletonUpdateEvent += OnSkelUpdate;
    }

    private void OnSkelUpdate(SkeletonData skeletonData)
    {
        for (int i = 0; i < riggedAvatars.Length; i++)
        {
            if (i < skeletonData.Skeletons.Length)
            {
                riggedAvatars[i].gameObject.SetActive(true);
                riggedAvatars[i].ProcessSkeleton(skeletonData.Skeletons[i]);
            }
            else
            {
                riggedAvatars[i].gameObject.SetActive(false);
            }
        }
    }
}
  1. Make 6 copies of RiggedAvatar (Unity Chan) (the number of copies depends on your needs, 6 is the maximum number of tracked skeletons in Nuitrack).
  2. Drag-and-drop all avatars to the SkeletonController/Rigged Avatars array in Editor. If you need other number of skeletons, please set the number using NuitrackManager.SkeletonTracker.SetNumActiveUsers(2);
2 Likes

Thanks a lot! I made something simular myself. Hopefully this helps future people as well. I saw no topics where made about this yet so. Thanks a lot for the help!

Greetings!

I realize this post is a few years old but I have a question about it if you are still available.

So I am implementing this scripting in order to get multiple skeletal tracking working. Being a newbie to C# this is likely a simple question… but when I set up the scripting as suggested, I get the following error: ‘cannot convert from nuitrack.Skeleton to NuitrackSDK.UserData.SkeletonData’. I get the red code on this line:
riggedAvatars[i].ProcessSkeleton(skeletonData.Skeletons[i]);

Can you advise as to what I am missing?

Thanks!!

Michael

Hello @mjrhoades

It’s old code.
Did you see this tutorial nuitrack-sdk/Unity_RGB_Skeletons.md at master · 3DiVi/nuitrack-sdk · GitHub or this post How can I recognize multiple people in the basic sample? - #3 by EugeneVasiliev ?

Thanks so much for your assistance Stephan… browsing to those locations now.

Michael

1 Like