Change the number of trackable people crashes

How would I go and change the number of users/skeletons Nuitrack may track during runtime?
Depending on which game I start, I want to change this amount. I found the function:
skeletonTracker.SetNumActiveUsers(_trackableAmount);

But this does not appear to work. If I put it on 1, and the second user walks into the frame, Unity3D crashes.
I use a get/setter for this and change it from another script.

Example:

    public int TrackableAmount {
        get { return _trackableAmount; }
        set 
        {
            _trackableAmount = value;
            skeletonTracker.SetNumActiveUsers(_trackableAmount);
        }
    }

En then i set it from another script using:

public void SetPlayerAmount(int amount)
{
InputManager.TrackableAmount = amount;
}

If I put the amount on 2, We can play the game with 2 people, If I put the amount on 1, the first person goes right, but when a second person walks into the screen the model for this person gets activated through the onnewuserevent, and then Unity crashes. Meaning that eventhough I set it to 1 user, it still gets into a newuserevent when someone else walks into the screen.

Idk what the problem is, it finds a second user but then crashes somewhere? Maybe because I said the numactiveusers to 1 through the skeletontracker, meaning it may not track someone else, but then it finds a second person? Idk…

Any ideas?

To clarify: I want to be able to specify the number of players a game can/may have per game through a setting.

Anyone?, im kinda stuck here…

Hi Patrick,

Sorry for a delayed reply.

You can check out this sample project for tracking of multiple skeletons (up to 6).

Hi Olga, I know how to track multiple users. The problem is tracking less users. Chaning the skeletontracker.SetNumActiveUsers makes nuitrack only track my desires skeletons(which is good). But it still reads the users. If I put it at 0, it should not receive a onnewuserevent…

Sorry for misunderstanding. The number of users cannot be changed (there are always 6 users). You have to add some kind of checking to your code (it’s hard to advise anything specific because we haven’t seen your project).

That’s what I currently do yes. I really hoped for a solid solution on the nuitrack site. Limiting the amount of skeletons tracked is not really effective if users are still getting tracked and you receive a userupdateevent.