From 705d46820c6ab9737ba20af68d591dd50c343b15 Mon Sep 17 00:00:00 2001 From: Louis Hobbs Date: Mon, 29 May 2023 01:36:59 +0100 Subject: [PATCH] Add Interactable Actor Component interaction on weapon hit --- Source/Nakatomi/PlayerCharacter.cpp | 5 +++++ Source/Nakatomi/PlayerCharacter.h | 1 + 2 files changed, 6 insertions(+) diff --git a/Source/Nakatomi/PlayerCharacter.cpp b/Source/Nakatomi/PlayerCharacter.cpp index db3f6fe..34cde4f 100644 --- a/Source/Nakatomi/PlayerCharacter.cpp +++ b/Source/Nakatomi/PlayerCharacter.cpp @@ -279,6 +279,11 @@ void APlayerCharacter::ProcessHits(TArray hits) if (Hit.GetActor()) { + if (auto interactableComponent = Hit.GetActor()->GetComponentByClass()) + { + interactableComponent->Interact(); + } + if (Hit.GetActor()->ActorHasTag("Enemy")) { // TODO: Do thing diff --git a/Source/Nakatomi/PlayerCharacter.h b/Source/Nakatomi/PlayerCharacter.h index d9b48ad..599dfbe 100644 --- a/Source/Nakatomi/PlayerCharacter.h +++ b/Source/Nakatomi/PlayerCharacter.h @@ -13,6 +13,7 @@ #include "Engine/DamageEvents.h" #include "Blueprint/UserWidget.h" #include "Perception/AIPerceptionStimuliSourceComponent.h" +#include "InteractableComponent.h" #include "PlayerCharacter.generated.h" class UInputAction;