diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactors/GrabComponent.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactors/GrabComponent.cpp index 32df40be5c43d29f66c99351bd0c28165ec48c48..fd8d0c295aa3dc4c76287940f4b40372e16645a1 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactors/GrabComponent.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactors/GrabComponent.cpp @@ -28,6 +28,7 @@ void UGrabComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorC TArray<UInteractableComponent*> CurrentGrabCompsInRange; TArray<AActor*> ActorsToIgnore; + ActorsToIgnore.Add(GetOwner()); TArray<FHitResult> OutHits; const ETraceTypeQuery TraceType = UEngineTypes::ConvertToTraceType(ECollisionChannel::ECC_PhysicsBody); @@ -43,6 +44,10 @@ void UGrabComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorC AActor* HitActor = Hit.GetActor(); if (HitActor) { + if(HitActor->IsChildActor()) + { + HitActor = HitActor->GetParentActor();// search at parent if found actor is a child actor + } UInteractableComponent* Grabbable = HitActor->FindComponentByClass<UInteractableComponent>(); if (Grabbable && Grabbable->HasInteractionTypeFlag(EInteractorType::Grab) && Grabbable->IsInteractable) { @@ -119,4 +124,4 @@ void UGrabComponent::OnEndGrab(const FInputActionValue& Value) { Grabbale->HandleOnActionEndEvents(this, GrabInputAction, Value, EInteractorType::Grab); } -} +} \ No newline at end of file