public void Pickup() { // Get nearest m_CurrentInteracteble = GetNearestInteractable(); // Null check if (!m_CurrentInteracteble) { return; } // Already held, check if (m_CurrentInteracteble.m_ActiveHand) { m_CurrentInteracteble.m_ActiveHand.Drop(); } // Position m_CurrentInteracteble.transform.position = transform.position; // Attach Rigidbody targetBody = m_CurrentInteracteble.GetComponent <Rigidbody>(); m_Joint.connectedBody = targetBody; // Set active hand m_CurrentInteracteble.m_ActiveHand = this; }
public void Drop() { // Null check if (!m_CurrentInteracteble) { return; } // Aply velocity Rigidbody targetBody = m_CurrentInteracteble.GetComponent <Rigidbody>(); targetBody.velocity = m_Pose.GetVelocity(); targetBody.angularVelocity = m_Pose.GetAngularVelocity(); // Detach m_Joint.connectedBody = null; // Clear m_CurrentInteracteble.m_ActiveHand = null; m_CurrentInteracteble = null; }