Hello, I’m developing a game at my university with motion capture to help seniors to practice physical exercises. The scenario is a physiotherapy clinic and in order not to be repetitive each session I put the avatar in a different position and angle. The problem is that the bones are moved by the global position (in the example script on the website) and if the avatar is turned, everything is wrong. Does anyone have a suggestion on how to solve? Currently I move the scenario all instead of the avatar, but I don’t see it as a final solution. I am grateful if someone has a suggestion
Are you moving all the bones using only real positions obtained from Nuitrack?
You should try applying only rotation to all the joints and to change the position of the whole avatar through the waist bone position ( root bone). The position vector can then be manipulated in different ways so that you can place the character in a different position. I am currently using the floor position (from userFrame) to calculate the waist position vector with respect to the floor rather than the camera. Therefore, my avatar can move respective to a floor plane in Unity. Hope this provides some insight into your problem.
Also, My PhD project is quite similar to yours!
Hi Nikhil, thanks for sharing your solution, I will try to use the userFrame floor position.
In fact, I use almost the same solution as you too, fixed the position of the xz waist axes in the desired place and only use rotations in the other bones as well. To position the avatar works well, however, the default rotations used in the script are global so if I rotate the y-axis
of the avatar along with the camera for a certain part of the scene the rotations will be wrong. I need to figure out how to be able to rotate the avatar without affecting bone rotations. Maybe convert the global rotation to local or subtract the y rotation from the avatar in the y rotation of the bones, or something.
I see what you mean. What about taking the root quaternion rotation of your model and then adding that to both the tracked bone rotation. It should be simply taking to transform.rotation quaternion of the root node (for example the waist bone) then just multiply that by the tracked bone rotation quaternion. That may work? Unless you already figured out something.
I tried to add degrees on the axis in the script itself, multiplying quaternions in several ways, but it didn’t work. But I will leave that aside, for now I move the scenario by coroutine and it is smooth and imperceptible.
My next problem is to make the avatar height correct. Depending on the height and distance of the sensor it is still wrong, even using the floor height. If I walk backwards my avatar floats up and if I walk forward it goes down.
There are squat exercises and sitting on the chair, so the avatar cannot vary the position too much or people will have difficulty using it. Does that happen in your script too? I’m trying to base the height on the distance but I didn’t arrive at a complete solution. If I can’t, I will have to specify exactly the height and distance of the sensor for users
Thank you for your help!
Are you applying the tracking position to the waist bone (this should be the root bone of your skeleton model). Also, make sure your not using transform.localPosition when applying the tracking position data. As the local co-ordinate axis maybe be orientated in different ways. In your situation it looks like the local z position is actually aligned to the global y position?
Yes the waist bone is the root of my avatar, and I am using transform.position which is global. The alignment of the axes is correct, if I move backwards the avatar goes backwards but it also fluctuates a little upwards, and vice versa. I’m going to work on the game now, if you want I can email you a video of the game and talk more about our projects. I’m using Orbbec Astra for capture, will it change if I use another sensor?
Yeah it would be awesome to talk about our projects, since they sound so similar. I don’t think there as any way to privately message you on here with my email address. Have you got a linkedin profile?
Check out the Motion Capture tutorial.
To record movements outside of the Unity editor, you need to save the movements to a custom file.
Please let me know if you have any other questions.
The tutorial is very useful. But the problem was different, it has already been solved. Thanks!