Hi, I’m testing some possibilities to build a FSM for my CharacterController. Would it be a good approach to define each State as an ActorComponent and create/destroy them as I need? For now it’s the best option I found in terms of functionality and easy/nice to develop with. However I don’t know if there is any downsides that I’m not aware of. Here is a code sample
void ACharacterController::ChangeState(TSubclassOf<UBaseStateComponent> NewState)
{
if(CurrentState)
{
CurrentState->ExitState();
CurrentState->DestroyComponent();
}
CurrentState = Cast<UBaseStateComponent>(AddComponentByClass(NewState, false, FTransform::Identity,false));
AddInstanceComponent(CurrentState);
CurrentState->EnterState();
}