From 3e60730d79076f3b8c4711c698581e5cfb4cad5b Mon Sep 17 00:00:00 2001 From: Daniel Rupp <daniel.rupp@rwth-aachen.de> Date: Mon, 20 Nov 2023 14:54:32 +0100 Subject: [PATCH] fix(interaction): change hit actor to parent, hit actor of sphere cast is a child actor --- .../Private/Interaction/Interactors/GrabComponent.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactors/GrabComponent.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactors/GrabComponent.cpp index 32df40be..fd8d0c29 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 -- GitLab