Fix crash with debug msg and fix state self transition issue

This commit is contained in:
Kevin Poretti 2023-07-29 21:54:21 -04:00
parent e032ddaaa5
commit 87c2aafd49
2 changed files with 10 additions and 4 deletions

View File

@ -35,6 +35,12 @@ void AFFPlayerController::FixedTick(float OneFrame)
bool AFFPlayerController::CheckInputSequences(const TArray<FFFInputSequence>& InputSequences) bool AFFPlayerController::CheckInputSequences(const TArray<FFFInputSequence>& InputSequences)
{ {
// no input conditions to check
if(InputSequences.IsEmpty())
{
return true;
}
for(const FFFInputSequence& ThisInputSequence : InputSequences) for(const FFFInputSequence& ThisInputSequence : InputSequences)
{ {
if(InputBuffer->CheckInputSequence(ThisInputSequence)) if(InputBuffer->CheckInputSequence(ThisInputSequence))

View File

@ -167,7 +167,8 @@ void UFFStateMachineComponent::FixedTick(float OneFrame)
for(UFFState* ThisState : States) for(UFFState* ThisState : States)
{ {
// found a state // found a state
if(ThisState->CanTransition(GetCurrentStateContext())) if(ThisState->CanTransition(GetCurrentStateContext()) &&
(CurrentState->Name != ThisState->Name || ThisState->bCanTransitionToSelf))
{ {
StateToTransitionTo = ThisState; StateToTransitionTo = ThisState;
break; 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. // 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 // It is OK to transition if state's "CanTransitionToSelf" is true
if(StateToTransitionTo && if(StateToTransitionTo)
(CurrentState->Name != StateToTransitionTo->Name || StateToTransitionTo->bCanTransitionToSelf))
{ {
GoToState(StateToTransitionTo); GoToState(StateToTransitionTo);
} }
@ -213,7 +213,7 @@ void UFFStateMachineComponent::TickComponent(float DeltaTime, ELevelTick TickTyp
Super::TickComponent(DeltaTime, TickType, ThisTickFunction); Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// Debug // Debug
if(StateMachineDebug) if(StateMachineDebug && CurrentState)
{ {
FString SMDebugString = "---State Machine Info---\n"; FString SMDebugString = "---State Machine Info---\n";
SMDebugString.Append(FString::Printf(TEXT("Current State: %s\n"), *CurrentState->Name.ToString())); SMDebugString.Append(FString::Printf(TEXT("Current State: %s\n"), *CurrentState->Name.ToString()));