diff --git a/Source/UnrealFightingFramework/Input/FFInputBufferComponent.cpp b/Source/UnrealFightingFramework/Input/FFInputBufferComponent.cpp index f34fc0d..52f0d0e 100644 --- a/Source/UnrealFightingFramework/Input/FFInputBufferComponent.cpp +++ b/Source/UnrealFightingFramework/Input/FFInputBufferComponent.cpp @@ -36,6 +36,10 @@ bool UFFInputBufferComponent::CheckInputSequence(const FFFInputSequence& InputSe switch (RequiredButtonState) { // TODO: should it be (PrevInput & RequiredButtons) == RequiredButtons or what we have now? + // TODO: If you have a sequence that is defined as something like button 1 pressed + button 2 pressed + // and the buttons are pressed on the same exact frame, then this implementation will not + // account for that. We should keep checking the sequences against the current frame's + // inputs until no sequences are detected, then continue on checking through the input buffer. case EFFButtonState::BTNS_Pressed: if(!(PrevInput & RequiredButtons | PrevDisable) && CurrInput & RequiredButtons & ~CurrDisable) diff --git a/Source/UnrealFightingFramework/State/FFState.cpp b/Source/UnrealFightingFramework/State/FFState.cpp index 97a196f..c65d4d5 100644 --- a/Source/UnrealFightingFramework/State/FFState.cpp +++ b/Source/UnrealFightingFramework/State/FFState.cpp @@ -64,6 +64,15 @@ bool UFFState::CanTransition(const FFFStateContext& InStateContext) void UFFState::Enter(const FFFStateContext& InStateContext) { PlayMontage(InStateContext); + + if(bDisableMostRecentInputOnEntry) + { + IFFStateOwnerInterface* PC = Cast(InStateContext.Owner); + if(PC) + { + PC->DisableMostRecentInput(); + } + } OnEnter(InStateContext); } diff --git a/Source/UnrealFightingFramework/State/FFState.h b/Source/UnrealFightingFramework/State/FFState.h index bee5756..18e5243 100644 --- a/Source/UnrealFightingFramework/State/FFState.h +++ b/Source/UnrealFightingFramework/State/FFState.h @@ -112,6 +112,13 @@ public: UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties") TArray InputSequences; + /** + * Should the most recent input in the controlling player's input buffer be disabled when + * entering this state? + */ + UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category="UFF State Properties") + bool bDisableMostRecentInputOnEntry = true; + /** * If true the state can transition from itself into itself without having to go through * another state like Idle diff --git a/Source/UnrealFightingFramework/State/FFStateMachineComponent.cpp b/Source/UnrealFightingFramework/State/FFStateMachineComponent.cpp index 04bc928..e0ddcef 100644 --- a/Source/UnrealFightingFramework/State/FFStateMachineComponent.cpp +++ b/Source/UnrealFightingFramework/State/FFStateMachineComponent.cpp @@ -102,19 +102,7 @@ void UFFStateMachineComponent::GoToState(UFFState* NewState, EFFStateFinishReaso { check(CurrentState); check(NewState); - - // if state being transitioned into requires an input sequence we need to disable the most - // recent input in the player controller input buffer to prevent unwanted "double firing" of - // actions that have short durations but very lenient required input sequences - if(NewState->InputSequences.Num() > 0) - { - IFFStateOwnerInterface* PC = Cast(Owner); - if(PC) - { - PC->DisableMostRecentInput(); - } - } - + CurrentState->Exit(GetCurrentStateContext(), StateFinishReason); TicksInState = 0; OnLandedTick = 0;