// Update is called once per frame void Update() { eou.Init(); var t = eou.GetTransformBySerialNumber(serialNumber); eou.SetGameObjectTransform(ref Tracker, t); var p = Tracker.transform.position; //Tracker.transform.position = p + t.position - old.position; var q = Tracker.transform.rotation; //Tracker.transform.rotation = q * t.rotation * Quaternion.Inverse(old.rotation); p = Tracker2.transform.position; p[0] = p[0] + t.velocity[0] * Time.deltaTime; p[1] = p[1] + t.velocity[1] * Time.deltaTime; p[2] = p[2] + t.velocity[2] * Time.deltaTime; Tracker2.transform.position = p; var r = Tracker2.transform.rotation.eulerAngles; r[0] = r[0] + Mathf.Rad2Deg * (t.angularVelocity[0] * Time.deltaTime); r[1] = r[1] + Mathf.Rad2Deg * (t.angularVelocity[1] * Time.deltaTime); r[2] = r[2] + Mathf.Rad2Deg * (t.angularVelocity[2] * Time.deltaTime); Tracker2.transform.rotation = Quaternion.Euler(r); old = t; }
void Update() { if (!eou.IsReady()) { eou.StartOpenVR(); } if (HMD_Offset == null || LeftHand_Offset == null || RightHand_Offset == null) { HMD_Offset = eou.GetHMDTransform(); LeftHand_Offset = eou.GetLeftControllerTransform(); RightHand_Offset = eou.GetRightControllerTransform(); } eou.AutoExitOnQuit(); _config = configManager.GetConfig(); HMDTrans = eou.GetHMDTransform(); LeftHandTrans = eou.GetLeftControllerTransform(); RightHandTrans = eou.GetRightControllerTransform(); eou.SetGameObjectTransform(ref HMD, HMDTrans); eou.SetGameObjectTransform(ref LeftHand, LeftHandTrans); eou.SetGameObjectTransform(ref RightHand, RightHandTrans); eou.SetGameObjectTransformWithOffset(ref HMD_withOffset, HMDTrans, HMD_Offset); eou.SetGameObjectTransformWithOffset(ref LeftHand_withOffset, LeftHandTrans, LeftHand_Offset); eou.SetGameObjectTransformWithOffset(ref RightHand_withOffset, RightHandTrans, RightHand_Offset); ulong button; if (isFollowRightHand) { eou.GetControllerButtonPressed(eou.GetRightControllerIndex(), out button); } else { eou.GetControllerButtonPressed(eou.GetLeftControllerIndex(), out button); } if (button != 0) { V_Chest.SetActive(false); V_Foot_L.SetActive(false); V_Foot_R.SetActive(false); V_Offset.SetActive(false); } if (_config.isMenuLeftHand && LeftHandTrans != null && LeftHandTrans.velocity.y < -3.5f || _config.isMenuRightHand && RightHandTrans != null && RightHandTrans.velocity.y < -3.5f) { if (!MenuManager.IsActive() && (!_config.isMenuLock || _config.MenuLockButton == 0 || _config.MenuLockButton == button)) { MenuManager.Open(); } } else if (_config.isMenuLeftHand && LeftHandTrans != null && LeftHandTrans.velocity.y > 3.5f || _config.isMenuRightHand && RightHandTrans != null && RightHandTrans.velocity.y > 3.5f) { if (MenuManager.IsActive() && (!_config.isMenuLock || _config.MenuLockButton == 0 || _config.MenuLockButton == button)) { MenuManager.Close(); } } }