OnNewUser and OnLostUser

How do I call these functions. I have tried the code below but it didn’t work.
UserTracker.OnLostUser LostUser = delegate { OnLostUser(); };

EDIT:
Okay I have got the update working but the new user and lost user still does not work.
This is my code

void Awake() 
{ 
    NuitrackManager.skeletonTracker.SetNumActiveUsers(3);
    NuitrackManager.skeletonTracker.SetAutoTracking(true);
    NuitrackManager.skeletonTracker.OnNewUserEvent += SkeletonTracker_OnNewUserEvent;
    NuitrackManager.skeletonTracker.OnLostUserEvent += SkeletonTracker_OnLostUserEvent;
    NuitrackManager.skeletonTracker.OnSkeletonUpdateEvent += SkeletonTracker_OnSkeletonUpdateEvent;
}

private void SkeletonTracker_OnNewUserEvent(SkeletonTracker skeletonTracker, int userID) {
    print(userID + " Joined");
}

private void SkeletonTracker_OnLostUserEvent(SkeletonTracker skeletonTracker, int userID) {
    print(userID + " Left");
}

private void SkeletonTracker_OnSkeletonUpdateEvent(SkeletonData SkeletonData) {
    print("Update");
}

Hi TheNoNinja,

At the moment, these events are not implemented in skeletonTracker. Instead, you can use similar events from userTracker.

I added the userTracker in but now when there enters a user unity freezes but it is no memory leak. May you know what it is?

using UnityEngine;
using nuitrack;
using System.Collections.Generic;

public class NativeAvatar : MonoBehaviour {

    [Range(1,6)]
    public int MaxUsers; //The Max Number of users
    public List<CustomSkeleton> Skeletons = new List<CustomSkeleton>(); //The active custom skeletons

    private SkeletonTracker skeletonTracker; //The skeleton tracker
    private UserTracker userTracker;
    public int PreviousNumberOfSkeletons = 0; //Number of previos Skeletons
    public bool[] AvailableSpots; // Custom id system

    //Run one on awake. 
    void Awake() {
        //Set the skeleton tracker
        skeletonTracker = SkeletonTracker.Create();
        skeletonTracker.SetNumActiveUsers(MaxUsers);
        skeletonTracker.SetAutoTracking(true);
        skeletonTracker.OnSkeletonUpdateEvent += SkeletonTracker_OnSkeletonUpdateEvent;

        userTracker = UserTracker.Create();
        userTracker.OnNewUserEvent += UserTracker_OnNewUserEvent;
        userTracker.OnLostUserEvent += UserTracker_OnLostUserEvent;

        //Make the custom ID list
        AvailableSpots = new bool[MaxUsers];
    }

    //Run every frame
    private void SkeletonTracker_OnSkeletonUpdateEvent(SkeletonData skeletonData) {

        foreach (CustomSkeleton skeleton in Skeletons) {
            skeleton.Update();
        }
    }

    private void UserTracker_OnNewUserEvent(int userID) {
        int newID = AvailableID();

        if (newID >= 0) {
            Skeleton OriginalSkeleton = skeletonTracker.GetSkeletonData().GetSkeletonByID(userID);
            CustomSkeleton TempCustomSkeleton = new CustomSkeleton(OriginalSkeleton, newID);
            Skeletons.Add(TempCustomSkeleton);
        }
    }

    private void UserTracker_OnLostUserEvent(int userID) {
        PreviousNumberOfSkeletons--;
        CustomSkeleton LeftSkeleton = null;

        foreach (CustomSkeleton skeleton in Skeletons) {
            Skeleton OriginalSkeleton = skeletonTracker.GetSkeletonData().GetSkeletonByID(userID);
            if (OriginalSkeleton == skeleton.OriginalSkeleton) {
                LeftSkeleton = skeleton;
            }
        }

        AvailableSpots[LeftSkeleton.ID] = false;
        Skeletons.Remove(LeftSkeleton);

    }

    private int AvailableID() {
        for (int i = 0; i < MaxUsers; i++) {
            if (!AvailableSpots[i]) {
                AvailableSpots[i] = true;
                return i;
            }
        }
        return -1;
    }
}

It seems that the problem is in the UserTracker_OnNewUserEvent method. Please try to check: if(skeletonTracker != null)

Sadly enough that did not help.

private void UserTracker_OnNewUserEvent(int userID) {
    if (skeletonTracker != null) {
        int newID = AvailableID();

        if (newID >= 0) {
            Skeleton OriginalSkeleton = skeletonTracker.GetSkeletonData().GetSkeletonByID(userID);
            CustomSkeleton TempCustomSkeleton = new CustomSkeleton(OriginalSkeleton, newID);
            Skeletons.Add(TempCustomSkeleton);
        }
    }
}

Did you use the check if(skeletonTracker != null) in all sections of code where you use skeletonTracker?

Also, please, take a look at our tutorial “Creating your First Unity Project using Nuitrack SDK” : Nuitrack SDK → Unity 3D → NuitrackSDK.unitypackage → Tutorials → First Project

I do check it on every function i have

Okay then, maybe you can send us the whole project so we can find out what is the problem? Contact our tech support: support-nuitrack@3divi.com