// Update is called once per frame void Update() { if (!isCalibrated) { if (UDPScript.IsDataReady(UPPER_LEG_L_ID)) { orig = Quaternion.Euler(-UDPScript.GetPitch(UPPER_LEG_L_ID), UDPScript.GetYaw(UPPER_LEG_L_ID), -UDPScript.GetRoll(UPPER_LEG_L_ID)); isCalibrated = true; } return; } if (Time.fixedTime >= timeToGo) { Quaternion q = Quaternion.Euler(-UDPScript.GetPitch(UPPER_LEG_L_ID), UDPScript.GetYaw(UPPER_LEG_L_ID), -UDPScript.GetRoll(UPPER_LEG_L_ID)); transform.rotation = Quaternion.Inverse(orig) * q * offset; timeToGo = Time.fixedTime + 0.1f; } }
// Update is called once per frame void Update() { if (!isCalibrated) { if (UDPScript.IsDataReady(UPPER_ARM_R_ID)) { orig = Quaternion.Euler(UDPScript.GetRoll(UPPER_ARM_R_ID), UDPScript.GetYaw(UPPER_ARM_R_ID), UDPScript.GetPitch(UPPER_ARM_R_ID)); isCalibrated = true; } return; } if (Time.fixedTime >= timeToGo) { //transform.rotation = Quaternion.Euler(offset.x - UDPScript.GetRoll(UPPER_ARM_R_ID), offset.y + UDPScript.GetYaw(UPPER_ARM_R_ID), // offset.z + UDPScript.GetPitch(UPPER_ARM_R_ID)); //Quaternion q = Quaternion.Euler(offset.x - UDPScript.GetRoll(UPPER_ARM_R_ID), offset.y + UDPScript.GetYaw(UPPER_ARM_R_ID), // offset.z + UDPScript.GetPitch(UPPER_ARM_R_ID)); //transform.localRotation = Quaternion.Inverse(transform.parent.rotation) * q; Quaternion q = Quaternion.Euler(-UDPScript.GetRoll(UPPER_ARM_R_ID), UDPScript.GetYaw(UPPER_ARM_R_ID), UDPScript.GetPitch(UPPER_ARM_R_ID)); transform.rotation = Quaternion.Inverse(orig) * q * offset; timeToGo = Time.fixedTime + 0.1f; } }