// set rotation for bone static void SetRotation(Transform[] transforms, InertialBones bone, Vector3 rotation) { Transform t = transforms[(int)bone]; if (t != null) { Quaternion rot = Quaternion.Euler(rotation); if (!float.IsNaN(rot.x) && !float.IsNaN(rot.y) && !float.IsNaN(rot.z) && !float.IsNaN(rot.w)) { t.localRotation = rot; } } }
// set position for bone static void SetPosition(Transform[] transforms, InertialBones bone, Vector3 pos) { Transform t = transforms[(int)bone]; if (t != null) { // calculate position when we have scale pos.Scale(new Vector3(1.0f / t.parent.lossyScale.x, 1.0f / t.parent.lossyScale.y, 1.0f / t.parent.lossyScale.z)); if (!float.IsNaN(pos.x) && !float.IsNaN(pos.y) && !float.IsNaN(pos.z)) { t.localPosition = pos; } } }