x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Proper way to add 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.

Product Version: UE 4.10
Tags:
more ▼

asked Apr 30 '16 at 03:07 AM in C++ Programming

avatar image

Boagz
50 14 21 28

avatar image Shadowriver Apr 30 '16 at 03:48 AM

What useful UCharacter functions you mean? some are tied with UCharacterMovmentComponent so you either use it or not

avatar image Boagz Apr 30 '16 at 04:13 AM

Well to be honest I can't really give specifics. I guess what I meant was the character class comes with a lot of functions and other components that are probably useful at some point. For example in UE4's character class there is a capsule component that is setup within it's constructor. If I were to inherit from pawn instead then I would have to setup my own capsule component, possibly messing up something with it's setup.

My dilemma is I would still want some of the default components/functionality of the character class (the functionality that I don't want to add custom code to) but also the ability to create my own components/functionality without duplicating code. If this is just not possible then that's okay but I was curious if this was the case or if there was a better way to do things.

avatar image Boagz Apr 30 '16 at 04:15 AM

I would like to be able to just inherit from UE4's character class and add custom components when needed but the more I would do that the greater the code duplication it seems.

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question