Actually initialize the input buffer on the AI controller

This commit is contained in:
Kevin Poretti 2023-12-05 22:23:16 -05:00
parent a074478f81
commit 5a967109fa
2 changed files with 7 additions and 0 deletions

View File

@ -5,6 +5,7 @@
AFFAIController::AFFAIController() AFFAIController::AFFAIController()
{ {
InputBuffer = CreateDefaultSubobject<UFFInputBufferComponent>(TEXT("InputBuffer"));
bWantsPlayerState = true; bWantsPlayerState = true;
} }
@ -25,5 +26,6 @@ FVector AFFAIController::GetInputAsWorldDirection() const
void AFFAIController::DisableMostRecentInput() void AFFAIController::DisableMostRecentInput()
{ {
check(InputBuffer);
InputBuffer->DisableMostRecentInput(); InputBuffer->DisableMostRecentInput();
} }

View File

@ -97,6 +97,11 @@ bool UFFInputBufferComponent::CheckInputSequence(const FFFInputSequence& InputSe
void UFFInputBufferComponent::DisableMostRecentInput() void UFFInputBufferComponent::DisableMostRecentInput()
{ {
if(InputBuffer.Num() < 2)
{
return;
}
InputBuffer[InputBuffer.Num() - 1].DisabledButtons |= InputBuffer[InputBuffer.Num() - 1].Buttons; InputBuffer[InputBuffer.Num() - 1].DisabledButtons |= InputBuffer[InputBuffer.Num() - 1].Buttons;
InputBuffer[InputBuffer.Num() - 2].DisabledButtons |= InputBuffer[InputBuffer.Num() - 2].Buttons; InputBuffer[InputBuffer.Num() - 2].DisabledButtons |= InputBuffer[InputBuffer.Num() - 2].Buttons;
} }