public void Pickup() { // Get nearest interactable m_CurrentInteractable = GetNearestInteractable(); // Null check if (!m_CurrentInteractable) { return; } //Already held check if (m_CurrentInteractable.m_ActiveHand) { m_CurrentInteractable.m_ActiveHand.Drop(); } // Heavy obj check if (m_CurrentInteractable.gameObject.CompareTag("Heavy")) { // If the other hand is not hovering over the same obj if (otherController.GetComponent <Hand>().m_ContactInteractables.IndexOf(m_CurrentInteractable) < 0) { return; } } // Already held, check if (m_CurrentInteractable.m_ActiveHand && m_CurrentInteractable.gameObject.CompareTag("Interactable")) { m_CurrentInteractable.m_ActiveHand.Drop(); m_CurrentInteractable.GetComponent <ColorManager>().changeToBlue(); } // Tyvex if (m_CurrentInteractable.gameObject.CompareTag("Tyvex")) { m_CurrentInteractable.gameObject.SetActive(false); // m_Player.NextStep(); return; } // OpenButton if (m_CurrentInteractable.gameObject.CompareTag("OpenButton")) { m_CurrentInteractable.gameObject.SetActive(false); // Play animation m_Animator.Play("Open", -1, 0f); // m_Player.NextStep(); return; } // CloseButton if (m_CurrentInteractable.gameObject.CompareTag("CloseButton")) { m_CurrentInteractable.gameObject.SetActive(false); // Reverse animation play m_Animator.SetFloat("Direction", -1.0f); m_Animator.Play("Open", -1, float.NegativeInfinity); // m_Player.NextStep(); return; } // Position // m_CurrentInteractable.transform.position = transform.position; if (m_CurrentInteractable.gameObject.CompareTag("trolley")) { m_CurrentInteractable.ApplyOffsetT(transform); } else { m_CurrentInteractable.ApplyOffset(transform); // Attach Rigidbody targetBody = m_CurrentInteractable.GetComponent <Rigidbody>(); m_Joint.connectedBody = targetBody; if (m_CurrentInteractable.gameObject.CompareTag("Heavy")) { otherController.GetComponent <Hand>().m_Pose.enabled = false; } } // Set active hand m_CurrentInteractable.m_ActiveHand = this; // Change color if (m_CurrentInteractable.gameObject.CompareTag("Flask")) { m_CurrentInteractable.GetComponent <ColorManager>().changeToClear(); } else { m_CurrentInteractable.GetComponent <ColorManager>().changeToBlue(); } }