So, according to the nuitrack tutorials, in the moveriggedmodel class we get the torsoPos and rotate other joints around this torso. However, I want to move another gameobject with a certain joint. I have the joints real and proj pos there, and they return the same value Nuitrack does, but the position of the actual joint is something like 0…0621313. I’m guessing because this is a child object of the 3D model. How would I move a gameobject with lets say the left hand from another class? I have the nuitrack joint data there, so I can ask Getjoint.ToVector3
NOTE: I do not have acces to the 3D model in that class. Only the nuitrack data
EDIT: We used to instantiate the object underneath the models gameobject. But we made a new system and we would like to do this in the game itself, rather than the moveriggedmodel class
Please take a look at the script below. This simple skeleton is made of gameobjects, which are moved and rotated using the skeleton joint data.
using UnityEngine;
public class NativeAvatar : MonoBehaviour
{
public nuitrack.JointType[] typeJoint;
GameObject[] CreatedJoint;
public GameObject PrefabJoint;
void Start()
{
CreatedJoint = new GameObject[typeJoint.Length];
for (int q = 0; q < typeJoint.Length; q++)
{
CreatedJoint[q] = Instantiate(PrefabJoint);
CreatedJoint[q].transform.SetParent(transform);
}
}
void Update()
{
if (CurrentUserTracker.CurrentUser != 0)
{
nuitrack.Skeleton skeleton = CurrentUserTracker.CurrentSkeleton;
for (int q = 0; q < typeJoint.Length; q++)
{
//Get Joint
nuitrack.Joint joint = skeleton.GetJoint(typeJoint[q]);
//Move Joint
Vector3 newPosition = 0.001f * joint.ToVector3();
CreatedJoint[q].transform.localPosition = newPosition;
//Rotate Joint
Quaternion jointOrient = joint.ToQuaternion();
CreatedJoint[q].transform.localRotation = jointOrient;
}
}
}
}