// Apply the rotations tracked by kinect to the joints. protected bool TransformBone(client.SkeletonPositionIndex joint, int boneIndex) { Transform boneTransform = bones[boneIndex]; if (boneTransform == null || c == null) { return(false); } int iJoint = (int)joint; if (iJoint < 0) { return(false); } // Get Kinect joint orientation Quaternion jointRotation = c.GetJointOrientation(iJoint); if (jointRotation == Quaternion.identity) { return(false); } // Smoothly transition to the new rotation Quaternion newRotation = Kinect2AvatarRot(jointRotation, boneIndex); if (smoothFactor != 0f) { boneTransform.rotation = Quaternion.Slerp(boneTransform.rotation, newRotation, smoothFactor * Time.deltaTime); } else { boneTransform.rotation = newRotation; } return(true); }