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); } }