void OnTriggerStay(Collider otherCollider) { if (m_grabbedObj == null) { grabbable = otherCollider.gameObject.GetComponent <CEGrabbable>(); if (isPressed && grabbable != null && m_grabbedObj == null) { touchedObj = otherCollider.gameObject; grabbable.isGrabbed = true; PickUp(); } } }
public void Drop() { // Destroy the joint between var fixJoint = gameObject.GetComponent <FixedJoint>(); Destroy(fixJoint); OVRPose localPose = new OVRPose { position = OVRInput.GetLocalControllerPosition(m_controller), orientation = OVRInput.GetLocalControllerRotation(m_controller) }; OVRPose offsetPose = new OVRPose { position = m_anchorOffsetPosition, orientation = m_anchorOffsetRotation }; localPose = localPose * offsetPose; OVRPose trackingSpace = transform.ToOVRPose() * localPose.Inverse(); Vector3 linearVelocity = trackingSpace.orientation * OVRInput.GetLocalControllerVelocity(m_controller); Vector3 angularVelocity = trackingSpace.orientation * OVRInput.GetLocalControllerAngularVelocity(m_controller); m_grabbedObj = null; grabbable.Drop(linearVelocity, angularVelocity); grabbable = null; }