From 9de243b254167697c28ba4290bc6d5debf907514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=B6mer?= <mp455017@win.rz.rwth-aachen.de> Date: Mon, 15 Nov 2021 16:26:56 +0100 Subject: [PATCH] Check if actor is null before checking interfaces --- .../Private/Pawn/BasicVRInteractionComponent.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/RWTHVRToolkit/Private/Pawn/BasicVRInteractionComponent.cpp b/Source/RWTHVRToolkit/Private/Pawn/BasicVRInteractionComponent.cpp index b9e62ccb..a19bc88d 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/BasicVRInteractionComponent.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/BasicVRInteractionComponent.cpp @@ -63,7 +63,7 @@ void UBasicVRInteractionComponent::BeginInteraction() PressPointerKey(EKeys::LeftMouseButton); - if (HitActor->Implements<UGrabable>() && Hit->Distance < MaxGrabDistance) + if (HitActor && HitActor->Implements<UGrabable>() && Hit->Distance < MaxGrabDistance) { // call grabable actors function so he reacts to our grab IGrabable::Execute_OnBeginGrab(HitActor); @@ -76,7 +76,7 @@ void UBasicVRInteractionComponent::BeginInteraction() // we save the grabbedActor in a general form to access all of AActors functions easily later GrabbedActor = HitActor; } - else if (HitActor->Implements<UClickable>() && Hit->Distance < MaxClickDistance) + else if (HitActor && HitActor->Implements<UClickable>() && Hit->Distance < MaxClickDistance) { IClickable::Execute_OnClick(HitActor, Hit->Location); } -- GitLab