I’m doing a lot of my game logic in C++, and I wanted to try and design things in a component based manner. From looking as some examples, it seems like most people move their player by calling a function on the character called AddMovementInput(), but it doesn’t look like this function is in any way tied to UCharacterMovementComponent.
The UCharacterMovementComponent looks huge… one script that handles how the character move on ground, water, and air. Am I understanding that correctly?
Anyways, let me try to break my confusion down into questions:
- Does the Character class have a
UCharacterMovementComponent attached
to it by default? - What types of
actors should I use
UCharacterMovementComponent on? - If I want to create custom components for movement, what class should I extend? UPawnMovementComponent class?
Lastly, since I’m going the route of components, does it make sense to make components audio, vfx, etc? Say, for example, my character swings a sword. If I create multicast events, i could have all of my components hook into the event, and when a button it pressed (in this example, the button is tied to swinging a sword), all of the components are notified of the actions. audio plays a sound. vfx plays effects. etc.
I’m not too sure how to approach the component based programming. I feel as if my pawn class (be it a character, plane, or whatever) should add all of the components it cares about, the components initialize and hook into the pawn’s events. Then everything just works… hopefully.
Thanks to everyone who has read my looooong question, and more thanks to the ones who attempt to answer I truly appreciate it.
- Austin