From 90af00227210c80a9e8a36cb000f3f53f9507428 Mon Sep 17 00:00:00 2001 From: Jamie Greunbaum Date: Sun, 10 Sep 2023 14:35:37 -0400 Subject: [PATCH] ComboManagerComponent now detects if it's in the PlayerController, instead of the PlayerCharacter, since that makes a bit more sense. --- .../Private/Components/ComboManagerComponent.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Source/ComboInput/Private/Components/ComboManagerComponent.cpp b/Source/ComboInput/Private/Components/ComboManagerComponent.cpp index 00ae124..890cad1 100644 --- a/Source/ComboInput/Private/Components/ComboManagerComponent.cpp +++ b/Source/ComboInput/Private/Components/ComboManagerComponent.cpp @@ -24,15 +24,14 @@ void UComboManagerComponent::BeginPlay() { Super::BeginPlay(); - // If this component's owner is the player character, attach it to the subsystem. - ACharacter *PlayerCharacter = UGameplayStatics::GetPlayerCharacter(this, 0); - if (this->GetOwner() == PlayerCharacter) + // If this component's owner is the player character or controller, attach it to the subsystem. + APlayerController *PlayerController = UGameplayStatics::GetPlayerController(this, 0); + if (this->GetOwner() == PlayerController) { - APlayerController *Controller = UGameplayStatics::GetPlayerController(this, 0); - UEnhancedInputComponent *InputComponent = Cast(Controller->InputComponent); - checkf(Controller, TEXT("Discovered controller is not a %s type."), *UEnhancedInputComponent::StaticClass()->GetName()); + UEnhancedInputComponent *InputComponent = Cast(PlayerController->InputComponent); + checkf(InputComponent, TEXT("Discovered player input component is not of type %s."), *UEnhancedInputComponent::StaticClass()->GetName()); - UInputBufferLocalPlayerSubsystem *InputBufferSubsystem = Controller->GetLocalPlayer()->GetSubsystem(); + UInputBufferLocalPlayerSubsystem *InputBufferSubsystem = PlayerController->GetLocalPlayer()->GetSubsystem(); InputBufferSubsystem->AttachComboManager(this, InputComponent); } }