Skip to content

Commit

Permalink
fix(SnapDropZone): check parent objects for interactable object as well
Browse files Browse the repository at this point in the history
It is plausible that an Interactable Object has a child collider that
triggers the snap drop zone, and therefore the parent's of that object
should be checked to see if they are a valid Interactable Object.
  • Loading branch information
thestonefox committed Nov 10, 2016
1 parent f1486af commit 4cb85af
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Assets/VRTK/Prefabs/Resources/Scripts/VRTK_SnapDropZone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public void InitaliseHighlightObject(bool removeOldObject = false)
/// <param name="objectToSnap">The GameObject to attempt to snap.</param>
public void ForceSnap(GameObject objectToSnap)
{
var ioCheck = objectToSnap.GetComponent<VRTK_InteractableObject>();
var ioCheck = objectToSnap.GetComponentInParent<VRTK_InteractableObject>();
if (ioCheck)
{
StopCoroutine("AttemptForceSnapAtEndOfFrame");
Expand Down Expand Up @@ -280,7 +280,7 @@ private void OnTriggerStay(Collider collider)

private VRTK_InteractableObject ValidSnapObject(GameObject checkObject, bool grabState)
{
var ioCheck = checkObject.GetComponent<VRTK_InteractableObject>();
var ioCheck = checkObject.GetComponentInParent<VRTK_InteractableObject>();
return (ioCheck && ioCheck.IsGrabbed() == grabState && !Utilities.TagOrScriptCheck(checkObject, validObjectTagOrScriptListPolicy, validObjectWithTagOrClass, true) ? ioCheck : null);
}

Expand Down Expand Up @@ -322,7 +322,7 @@ private void CheckCurrentValidSnapObjectStillValid()
//If there is a current valid snap object
if (currentValidSnapObject)
{
var currentIOCheck = currentValidSnapObject.GetComponent<VRTK_InteractableObject>();
var currentIOCheck = currentValidSnapObject.GetComponentInParent<VRTK_InteractableObject>();
//and the interactbale object associated with it has been snapped to another zone, then unset the current valid snap object
if (currentIOCheck && currentIOCheck.GetStoredSnapDropZone() != null && currentIOCheck.GetStoredSnapDropZone() != gameObject)
{
Expand Down

0 comments on commit 4cb85af

Please sign in to comment.