[SOLVED] Nuitrack & Unity loading scene takes 5 seconds

Hello all,

I am working on an interactive wall projection project where I have a main menu where people will be able to select among multiple games/interactions and once they’re done they can go back to the main menu.

The problem is that each game and the main menu are a Scene. Whenever I’m loading a scene the game pauses/freezes and it looks like the nuitrack has to reestablish the connection in some way. This is also visible in the nuitrack scripts where I can see what the camera sees and the camera also freezes when a scene is loading. When disabling the NuitrackScripts there is no pause/freeye, but that is not an option as that disables the Nuitrack controls.

I was thinking if Async Scene Loading was a solution but I don’t know if it works, or how I would go about doing that. I did try doing the async loading but I saw no difference that is why I don’t know if if it even works with nuitrack or if I implemented it correctly.

Is this just how nuitrack works with unity when loading scenes or is there anything else I can try out?

Hello @NUIty

That’s a good question.
You can do this:

  1. Create a scene and name it, for example, “InitScene”. In “Build Settings”, move it to the very beginning
  2. Add “NuitrackScripts” prefab to this scene
  3. The “NuitrackManager” component has the “Don’t destroy on load” checkbox by default. This means that this object will not be destroyed when switching scenes, and in this case “Nuitrack” will not stop\start every time.

You will probably also need to write a script that would load the next scene. You can put this component in the “Init Event” on the “Nuitrack Manager”. Then immediately after initialization, your scenes will be loaded with running “NuitrackScripts” in the background
4. Make sure that the “InitScene” scene will be started at the very beginning and only once. Also, there should be no “NuitrackManager” on ALL other scenes. Then the launch of “Nuitrack” will be performed only once when the application is launched and disabled when the application is closed.

“Async Init” does not speed up initialization, but only makes it asynchronous. If this option is enabled, the scene does not hang while “Nuitrack” is initialized and can work normally for this period of time (You can add a loading indicator, idle animation, or something else).

Thank you for the reply. I just got around testing it but I didn’t have any luck yet.

This is the setup that I tried. A simple scene with a cube so I can activate its trigger with the left/right hand. The reload script simply loads the main scene when the on trigger is detected. I’ve added the reload script to the cube and I then also added it to the Init Event. In the image I added the script to the Init Event which is probaby not correct.

I then added the cube to the Init Event and then selected either the on trigger enter event from the drop down list (the checkbox had to be enabled). I then also used the script name from the dropdown list and I entered OnTriggerEnter. Both times the scene loaded but was frozen. I tried using a simple loading bar and AsyncLoadScene method but the bar would immediatelly fully load but the scene was still loading.

When I enable the Async Init and start the scene for the first time I get 2 errors, one for Nuitrack Scripts and the other for my L/R hand controls. When the scene reloads, when triggering the cube, I get a bunch more errors and Unity crashes. I make the skeleton joints in the Start() method so I don’t know if I should be changing script execution orders or what.

I hope I can get something animatable to work, if not an almost instant load, but as a last resort I’ll see if I can load a still image during the loading process.

On a side note I noticed your Nuitrack Scripts have max active users, should I update something?

In your case, there should be two scenes. As I wrote earlier, this is an “init”-a scene where only NuitrackScripts prefab will be. It should run only once, at the start of the application. And second, this is the scene in the screenshot, it should not have NuitrackScripts prefab on it. This scene can be reloaded as many times as you want.
Async Init can be disabled for now

“max active users” you can change this value depending on how many users should be tracked for your application at the same time

Thank you again it is working now almost instantly. I was focusing too much on the test scene with the loading screen instead of just removing the NuitrackScripts prefab from my main and game scene. Once I did that and added an initScene, like you mentioned, the long loading times between the scenes are now gone.

As for max active users, I don’t see the setting, was this added with the recent update?

If this is not yet available in the latest version of the package on github, then this option will appear in the next update.
But if you want to use it now, you can change the value of “activeUsers”: 2, in the config file
(Program Files\Nuitrack\nuitrack\nuitrack\data\nuitrack.config)

On that note. Can this config value be changed on the fly with code or does it have to be set at startup? If we can’t change it on the fly yet, will we be able to change it once this value will be in the inspector?

As a follow-up question to the multiple people (should I make a new topic?)
First let me explain what I want to achieve. I was thinking about having one project with multiple games, one simple game for 1 person, then I could have another game for up to 2 people and then a third game would be a jumping game for up to 6 people (only jump/crouch, no moving left/right, each player in their own line).

I didn’t have the chance yet to test out Nuitrack with multiple people so I am wondering how the skeleton acquisiton works and also would a skeleton get reasigned from an active user if another person came into the camera view by accident?

As for the jumping game example I have in mind. Lets say I have 6 people lined up like so 1,2,3,4,5,6 (and they move up). I would also like the ingame characters to correspond to be controlled by the person with the same positon so 1,2,3,4,5,6 and not ie. 3,6,4,5,2,1. So that is why I would like to know if there is some kind of an action required for a person to be detected so I could link it to an ingame character.

The values that are in the configuration file are applied immediately before the launch of “Nuitrack”. This line replaces the values in the config (you can see NuitrackManager.cs for an example):

nuitrack.Nuitrack.SetConfigValue("Skeletonization.ActiveUsers", "2");

You can manually restart “nuitrack” so that the values are applied.

should I make a new topic?


I didn’t have the chance yet to test out Nuitrack with multiple people

It is better to test as early as possible. Because tracking 6 people is not the easiest task. In order for 6 people to fit into the frame, they must stand far away from the sensors, not all sensors will be able to work well at such a distance.

@NUIty do you have any more questions about this issue?

Thank you for all the help, regarding the loading times between the scenes everything has been cleared up.

1 Like