public void Drop() { // Null check if (!currentInteractable) { return; } // Method called before drop currentInteractable.OnDrop(this); // check if kinematic or physics based if (currentInteractable.GetComponent <Rigidbody>().isKinematic) { currentInteractable.transform.parent = null; } else { // Apply velocity Rigidbody targetBody = currentInteractable.GetComponent <Rigidbody>(); targetBody.velocity = pose.GetVelocity(); targetBody.angularVelocity = pose.GetAngularVelocity(); // Detach joint.connectedBody = null; } // Clear active hand currentInteractable.activeHand = null; currentInteractable = null; }
public void Pickup() { // Get nearest interactable currentInteractable = GetNearestInteractable(); // Null check if (!currentInteractable) { return; } // check if kinematic or physics based if (currentInteractable.GetComponent <Rigidbody>().isKinematic) { currentInteractable.transform.parent = this.transform; } else { // Position currentInteractable.ApplyOffset(transform); // Attach Rigidbody targetBody = currentInteractable.GetComponent <Rigidbody>(); joint.connectedBody = targetBody; } // Set active hand currentInteractable.activeHand = this; currentInteractable.OnPickup(this); }
public void Pickup() { // Get nearest interactable currentInteractable = GetNearestInteractable(); // Null check if (!currentInteractable) { return; } // Already held, check if (currentInteractable.m_ActiveHand) { currentInteractable.m_ActiveHand.Drop(); } // Position currentInteractable.ApplyOffset(transform); // Attach Rigidbody targetBody = currentInteractable.GetComponent <Rigidbody>(); joint.connectedBody = targetBody; // Set active hand currentInteractable.m_ActiveHand = this; currentInteractable.OnPickup(this); }
public void Drop() { // Null check if (!currentInteractable) { return; } // Method called before drop currentInteractable.OnDrop(this); // Apply velocity Rigidbody targetBody = currentInteractable.GetComponent <Rigidbody>(); targetBody.velocity = pose.GetVelocity(); targetBody.angularVelocity = pose.GetAngularVelocity(); // Detach joint.connectedBody = null; // Clear currentInteractable.m_ActiveHand = null; currentInteractable = null; }