I assumed that I should use the C# reference because I’m using Unity environment for my project.
This is what I did to my script:
…
public Vector3 normal;
private nuitrack.UserFrame UF = new nuitrack.UserFrame();
…
void Update()
{
if (cnt_update % 2 == 0) //camera was working in 30fps, while the update method was running in 60times/second
{
if (CurrentUserTracker.CurrentUser != 0) //if user is tracked
{
…
normal = UF.FloorNormal.ToVector3();
Debug.Log(normal);
…
…
And after running the project what I get is (0,0,0),
every time it prints the “normal vector” on the debugging console.
I’m a complete newbie on object-oriented languages…
Can anyone help me out? Thanks!
In NuitrackScripts(The Unity GameObject that contains necessary scripts, provided in Unity NuitrackSDK package), there is the script named CurrentUserTracker.cs. In this script I added some code to get floor data. You need to retrieve data whenever UserTracker is updated. That is why you should use events.
using UnityEngine;
using System.Collections;
...
public class CurrentUserTracker : MonoBehaviour
{
...
static nuitrack.Vector3 currentFloorNormal;
public static nuitrack.Vector3 CurrentFloorNormal {get { return currentFloorNormal; } }
static nuitrack.Vector3 currentFloor;
public static nuitrack.Vector3 CurrentFloor { get { return currentFloor; } }
...
void Start ()
{
DontDestroyOnLoad(this);
NuitrackManager.onSkeletonTrackerUpdate += NuitrackManager_onSkeletonTrackerUpdate;
NuitrackManager.onUserTrackerUpdate += NuitrackManager_onUserTrackerUpdate;
}
void NuitrackManager_onUserTrackerUpdate(nuitrack.UserFrame frame)
{
currentFloor = frame.Floor;
currentFloorNormal = frame.FloorNormal;
}
...
}