public override void Initialise(VRTK_InteractableObject currentGrabbdObject, VRTK_InteractGrab currentPrimaryGrabbingObject, VRTK_InteractGrab currentSecondaryGrabbingObject, Transform primaryGrabPoint, Transform secondaryGrabPoint) { base.Initialise(currentGrabbdObject, currentPrimaryGrabbingObject, currentSecondaryGrabbingObject, primaryGrabPoint, secondaryGrabPoint); ParentConstraint parentConstraint = secondaryInteractableToRemove.GetComponent <ParentConstraint>(); // Make sure that the assigned Interactable Object is still a child of this object bool isStillChild = secondaryInteractableToRemove.transform.IsChildOf(transform) || (parentConstraint != null && parentConstraint.sourceCount > 0 && parentConstraint.GetSource(0).sourceTransform == transform); if (isStillChild) { // First, remove from the parent from the secondary object so that it is not affected by it's movement if (parentConstraint != null) { // Note: We assume that the objects will only have 1 parent here parentConstraint.RemoveSource(0); parentConstraint.constraintActive = false; } else { secondaryInteractableToRemove.transform.parent = null; } // Set the Grabbable field to true so it can be grabbed secondaryInteractableToRemove.isGrabbable = true; secondaryInteractableToRemove.GetComponentInChildren <Collider>().enabled = true; secondaryInteractableToRemove.GetComponent <Rigidbody>().useGravity = true; // Force grab the object with the secondary grabbing object (the controller/hand) so that it can move with that object's motion currentGrabbdObject.ForceStopSecondaryGrabInteraction(); currentSecondaryGrabbingObject.interactTouch.ForceStopTouching(); currentSecondaryGrabbingObject.ForceRelease(); currentSecondaryGrabbingObject.interactTouch.ForceTouch(secondaryInteractableToRemove.gameObject); currentSecondaryGrabbingObject.AttemptGrab(); OnObjectRemovedFromParent(new EventArgs()); // Enable the GameObject holding the IA that will allow the object to be returned to the parent if (returnToParentInteractionAreaObject != null) { returnToParentInteractionAreaObject.SetActive(true); } } }
protected virtual void SnapObject(GameObject interactionObject, Transform snapOffset = null, bool objectIsGrabbable = false) { VRTK_InteractableObject currentInteractableObject = interactionObject.GetComponentInParent <VRTK_InteractableObject>(); //If the item is in a snappable position and this drop zone isn't snapped and the collider is a valid interactable object if (currentInteractableObject != null) { snappedObject = currentInteractableObject.gameObject; snappedAtFrame = Time.frameCount; // Make sure the object being snapped doesn't start to interfere with other objects if (!objectIsGrabbable) { currentInteractableObject.GetComponentInChildren <Collider>().enabled = false; } StartCoroutine(UpdateTransformDimensions(currentInteractableObject, snapDuration, snapOffset)); } }