Skip to content

Commit

Permalink
fix(Interaction): ensure trigger collision check is done every frame
Browse files Browse the repository at this point in the history
Previously, the `triggerIsColliding` bool was only set if an object
wasn't being touched which would cause the `StopTouching` method to
execute which caused problems with using objects.

This has now been fixed so the bool is set every `OnTriggerStay`
if no object is being touched or if the object being touched is the
same as the current touched object.
  • Loading branch information
thestonefox committed Jan 7, 2017
1 parent f8d0ec9 commit 4f3b68c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Assets/VRTK/Scripts/Interactions/VRTK_InteractTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,14 @@ private void OnTriggerExit(Collider collider)
private void OnTriggerStay(Collider collider)
{
var colliderInteractableObject = TriggerStart(collider);
if (touchedObject == null && colliderInteractableObject && IsObjectInteractable(collider.gameObject))

if (touchedObject == null || touchedObject == collider.gameObject)
{
triggerIsColliding = true;
}

if (touchedObject == null && colliderInteractableObject && IsObjectInteractable(collider.gameObject))
{
touchedObject = colliderInteractableObject;
var touchedObjectScript = touchedObject.GetComponent<VRTK_InteractableObject>();
var touchingObject = gameObject;
Expand Down

0 comments on commit 4f3b68c

Please sign in to comment.