Controlling moving of character using nuitrack sdk

Dear Ahmed Osman!

Try to use this script. To track the user’s movement left-right (relative to the body position), you need to save the previous position of the target joint, such as the torso, and compare it with the new one obtained in the current frame.

To determine the direction of displacement, we denote the “left” vector for the skeleton as a vector from the position of the right shoulder to the position of the left. Next, we need to get the displacement vector of the target joint as the difference between the vectors of the new position and the old one.

The last step is to use Vector3.Dot function, which returns value < 0 if the user moves to the right and value > 0 if to the left.

In the example script, a more detailed detection logic is implemented, taking into account “does not move”.

As for jumping. Nuitrack does not have a built-in function for detecting а jump, you need to check the distance to the floor for any joint, for example, LeftHip or RightHip.

Please let me know if you have any other questions.