From 4f3b68c4ebb60808252306ede74475e1d938e335 Mon Sep 17 00:00:00 2001 From: "Theston E. Fox" Date: Sat, 7 Jan 2017 21:55:24 +0000 Subject: [PATCH] fix(Interaction): ensure trigger collision check is done every frame 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. --- Assets/VRTK/Scripts/Interactions/VRTK_InteractTouch.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Assets/VRTK/Scripts/Interactions/VRTK_InteractTouch.cs b/Assets/VRTK/Scripts/Interactions/VRTK_InteractTouch.cs index 1d24d92e6..a0cf45b7d 100644 --- a/Assets/VRTK/Scripts/Interactions/VRTK_InteractTouch.cs +++ b/Assets/VRTK/Scripts/Interactions/VRTK_InteractTouch.cs @@ -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(); var touchingObject = gameObject;