diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactors/DirectInteractionComponent.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactors/DirectInteractionComponent.cpp index 18e515817875cb60c35090b4dbfb4300051b8dac..f759b37b054195e0c8af9d1646a9c2dedd3a85ae 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactors/DirectInteractionComponent.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactors/DirectInteractionComponent.cpp @@ -70,6 +70,13 @@ void UDirectInteractionComponent::TickComponent(float DeltaTime, ELevelTick Tick // Call hover end events on all components that were previously in range, but not anymore for (UInteractableComponent* PrevInteractableComp : PreviousInteractableComponentsInRange) { + // It can happen that a previous component was destroyed + if (!PrevInteractableComp || !PrevInteractableComp->IsValidLowLevel()) + { + ComponentsToRemove.Add(PrevInteractableComp); // might have to use indices here + continue; + } + if (!CurrentInteractableCompsInRange.Contains(PrevInteractableComp)) { ComponentsToRemove.AddUnique(PrevInteractableComp);