Download

Proper way to go about adding custom logic?

Hey everyone. My question is how am I suppose to go about adding my own custom C++/blueprint logic to objects in ue4? My confusion is explained better with an example. Say I want to create a character and so I go and inherit from ue4’s character class. After a bit I find I want to add additional functionality to the movement component. Now I could just create my own c++ movement component and add it to my derived character class. The problem is wouldn’t this be duplicating code since ue4’s character class already comes with a movement component? I do not want to add movement component logic within my base character class because, as good OO design goes, I do not want to give that class multiple responsibilities.

Instead, if I decide to inherit my character from say ue4’s pawn class, then I can add a custom movement component without worrying about duplicating code but then I wont get all the useful functions from ue4’s character class. Am I thinking about this the wrong way? Are there better ways to handle this? Any help is appreciated.

You could inherit from the UCharacterMovementComponent and then set your character to use UYourCustomMovComp instead of the normal one.