Is it OK for different characters in Unreal to have different ability system components? For example, we could create a base ability system component, and then our controlled character and enemies could each have their own ability components that are derived from the base ability ability component. Would this be a good design?
I ask bard, it gives me this answer:
Yes, different characters can have different ability system components in Unreal. In fact, this is a good design pattern to use. By having a base ability component, you can define common functionality that all characters can use. Then, you can create derived ability components for specific characters that add additional functionality. This allows you to keep your code DRY (Don’t Repeat Yourself) and makes it easier to maintain your game.
For example, you could have a base ability component that defines the following functionality:
- Ability activation
- Ability cancellation
- Ability input bindings
- Ability attribute management
Then, you could create derived ability components for specific characters that add additional functionality, such as:
- Player ability component: This component would add functionality for player-controlled characters, such as the ability to use a mouse and keyboard to control abilities.
- Enemy ability component: This component would add functionality for enemy-controlled characters, such as the ability to use AI to select targets and attack them.
This design pattern allows you to keep your code DRY and makes it easier to maintain your game. It also allows you to easily add new functionality to specific characters without having to change the base ability component.
Here are some of the benefits of using this design pattern:
- DRY code: By having a base ability component, you can define common functionality that all characters can use. This prevents you from having to duplicate code in multiple places, which can help to reduce bugs and make your code easier to maintain.
- Easier to add new functionality: If you need to add new functionality to a character, you can do so by creating a new derived ability component. This makes it easy to add new features to your game without having to change the base ability component.
- Flexible: This design pattern is flexible enough to be used in a variety of games. It can be used for both single-player and multiplayer games, and it can be used for both 2D and 3D games.
If you are planning to create a game with a large number of characters, then this design pattern is a good option to consider. It can help you to keep your code DRY, make it easier to add new functionality, and make your game more flexible.