Skip to content

Commit 4f3b68c

Browse files
committed
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.
1 parent f8d0ec9 commit 4f3b68c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Assets/VRTK/Scripts/Interactions/VRTK_InteractTouch.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,14 @@ private void OnTriggerExit(Collider collider)
295295
private void OnTriggerStay(Collider collider)
296296
{
297297
var colliderInteractableObject = TriggerStart(collider);
298-
if (touchedObject == null && colliderInteractableObject && IsObjectInteractable(collider.gameObject))
298+
299+
if (touchedObject == null || touchedObject == collider.gameObject)
299300
{
300301
triggerIsColliding = true;
302+
}
303+
304+
if (touchedObject == null && colliderInteractableObject && IsObjectInteractable(collider.gameObject))
305+
{
301306
touchedObject = colliderInteractableObject;
302307
var touchedObjectScript = touchedObject.GetComponent<VRTK_InteractableObject>();
303308
var touchingObject = gameObject;

0 commit comments

Comments
 (0)