Hi there, I have a question regarding the Command Pattern in UE5.
For some context, I am working on a hobby project—a turn-based tactical game where two teams fight each other. I am at the stage where I need to create a system that allows the player controller and the AI to perform various actions required for their turn, such as moving a unit to a specific point or shooting at a target. In my research, I came across the Command Pattern.
From my understanding, to use the Command Pattern correctly, one would create an abstract class or an interface for a command object. Child classes can then be created from this base class to issue specific commands, such as Move. The command’s execute function can be written within these child classes, allowing both the Player Controller and the AI to utilize the same function.
My question is, couldn’t I simply use a FunctionLibrary to call the command when needed? Creating a class just to use a function seems like an unnecessary extra step. I understand that allowing players to configure their input could be a reason to use this pattern, but Unreal Engine’s Enhanced Input system already handles this.
So, my question is: did I miss another benefit of creating a command abstract class instead of using a FunctionLibrary? Thank you for any clarification you can provide.