void Update() { head.center = headObject.transform.localPosition - new Vector3(0f, 0.2f, 0f); if (Controller1.GetHairTriggerDown() && hand1Colliding) { selectedControllerTransform = controller1Object.transform; oldPosition = selectedControllerTransform.position; Physics.gravity = Vector3.zero; //controller1MeshRenderer.material.color = new Color(0.2f, 0.2f, 0.2f); } if (Controller2.GetHairTriggerDown() && hand2Colliding) { selectedControllerTransform = controller2Object.transform; oldPosition = selectedControllerTransform.position; Physics.gravity = Vector3.zero; //controller2MeshRenderer.material.color = new Color(0.2f, 0.2f, 0.2f); } if (Controller1.GetHairTriggerUp()) { //controller1MeshRenderer.material.color = new Color(1f, 1f, 1f); if (selectedControllerTransform == controller1Object.transform) { selectedControllerTransform = null; Physics.gravity = defaultGravity; rigidbody.AddForce((oldPosition - controller1Object.transform.position) * 10000); } } if (Controller2.GetHairTriggerUp()) { //controller2MeshRenderer.material.color = new Color(1f, 1f, 1f); if (selectedControllerTransform == controller2Object.transform) { selectedControllerTransform = null; Physics.gravity = defaultGravity; rigidbody.AddForce((oldPosition - controller2Object.transform.position) * 10000); } } if (selectedControllerTransform) { rigidbody.velocity = Vector3.zero; transform.position = Vector3.Lerp( transform.position, transform.position + (oldPosition - selectedControllerTransform.position), 1f ); oldPosition = selectedControllerTransform.position; } if (transform.position.y < -10) { StartCoroutine(EndGame()); } }
private ControllerState controllerEvents() { #if SteamVR_Legacy if (Controller1.GetHairTriggerDown()) { return(ControllerState.TRIGGER_DOWN1); } if (Controller1.GetHairTriggerUp()) { return(ControllerState.TRIGGER_UP1); } if (Controller2.GetHairTriggerDown()) { return(ControllerState.TRIGGER_DOWN2); } if (Controller2.GetHairTriggerUp()) { return(ControllerState.TRIGGER_UP2); } #elif SteamVR_2 if (m_controllerPress.GetStateDown(trackedObj1.inputSource)) { return(ControllerState.TRIGGER_DOWN1); } if (m_controllerPress.GetStateUp(trackedObj1.inputSource)) { return(ControllerState.TRIGGER_UP1); } if (m_controllerPress.GetStateDown(trackedObj2.inputSource)) { return(ControllerState.TRIGGER_DOWN2); } if (m_controllerPress.GetStateUp(trackedObj2.inputSource)) { return(ControllerState.TRIGGER_UP2); } #endif return(ControllerState.NONE); }