From 218e78ba6601ac227767f5de742fb97539e006e1 Mon Sep 17 00:00:00 2001
From: David Gilbert <gilbert@vr.rwth-aachen.de>
Date: Tue, 23 Jul 2024 13:43:27 +0200
Subject: [PATCH] fix(interaction): Correctly clears currently interacted
 components array on interaction end.

---
 .../Interaction/Interactors/DirectInteractionComponent.cpp      | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactors/DirectInteractionComponent.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactors/DirectInteractionComponent.cpp
index c8cf9ce3..7c81cb80 100644
--- a/Source/RWTHVRToolkit/Private/Interaction/Interactors/DirectInteractionComponent.cpp
+++ b/Source/RWTHVRToolkit/Private/Interaction/Interactors/DirectInteractionComponent.cpp
@@ -120,6 +120,7 @@ void UDirectInteractionComponent::OnBeginInteraction(const FInputActionValue& Va
 	}
 	else
 	{
+		CurrentlyInteractedComponents.Empty();
 		CurrentlyInteractedComponents.Reserve(CurrentlyInteractedComponents.Num() +
 											  CurrentInteractableComponentsInRange.Num());
 		for (UInteractableComponent* InteractableComp : CurrentInteractableComponentsInRange)
@@ -139,6 +140,7 @@ void UDirectInteractionComponent::OnEndInteraction(const FInputActionValue& Valu
 			Component->HandleOnActionEndEvents(this, InteractionInputAction, Value, EInteractorType::Direct);
 		}
 	}
+	CurrentlyInteractedComponents.Empty();
 }
 
 UInteractableComponent* UDirectInteractionComponent::SearchForInteractable(AActor* HitActor)
-- 
GitLab