From 87c2aafd49aa49285714274128a32410addb9c4e Mon Sep 17 00:00:00 2001 From: Kevin Poretti Date: Sat, 29 Jul 2023 21:54:21 -0400 Subject: [PATCH] Fix crash with debug msg and fix state self transition issue --- .../UnrealFightingFramework/Input/FFPlayerController.cpp | 6 ++++++ .../State/FFStateMachineComponent.cpp | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Source/UnrealFightingFramework/Input/FFPlayerController.cpp b/Source/UnrealFightingFramework/Input/FFPlayerController.cpp index 0401d1f..7fe45cd 100644 --- a/Source/UnrealFightingFramework/Input/FFPlayerController.cpp +++ b/Source/UnrealFightingFramework/Input/FFPlayerController.cpp @@ -35,6 +35,12 @@ void AFFPlayerController::FixedTick(float OneFrame) bool AFFPlayerController::CheckInputSequences(const TArray& InputSequences) { + // no input conditions to check + if(InputSequences.IsEmpty()) + { + return true; + } + for(const FFFInputSequence& ThisInputSequence : InputSequences) { if(InputBuffer->CheckInputSequence(ThisInputSequence)) diff --git a/Source/UnrealFightingFramework/State/FFStateMachineComponent.cpp b/Source/UnrealFightingFramework/State/FFStateMachineComponent.cpp index 4af0eb3..286b4dd 100644 --- a/Source/UnrealFightingFramework/State/FFStateMachineComponent.cpp +++ b/Source/UnrealFightingFramework/State/FFStateMachineComponent.cpp @@ -167,7 +167,8 @@ void UFFStateMachineComponent::FixedTick(float OneFrame) for(UFFState* ThisState : States) { // found a state - if(ThisState->CanTransition(GetCurrentStateContext())) + if(ThisState->CanTransition(GetCurrentStateContext()) && + (CurrentState->Name != ThisState->Name || ThisState->bCanTransitionToSelf)) { StateToTransitionTo = ThisState; break; @@ -176,8 +177,7 @@ void UFFStateMachineComponent::FixedTick(float OneFrame) // Lastly just check if the state we're about to transition into isn't the current state. // It is OK to transition if state's "CanTransitionToSelf" is true - if(StateToTransitionTo && - (CurrentState->Name != StateToTransitionTo->Name || StateToTransitionTo->bCanTransitionToSelf)) + if(StateToTransitionTo) { GoToState(StateToTransitionTo); } @@ -213,7 +213,7 @@ void UFFStateMachineComponent::TickComponent(float DeltaTime, ELevelTick TickTyp Super::TickComponent(DeltaTime, TickType, ThisTickFunction); // Debug - if(StateMachineDebug) + if(StateMachineDebug && CurrentState) { FString SMDebugString = "---State Machine Info---\n"; SMDebugString.Append(FString::Printf(TEXT("Current State: %s\n"), *CurrentState->Name.ToString()));