Announcement

Collapse
No announcement yet.

Custom C++ Class with multiple inheritance

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Custom C++ Class with multiple inheritance

    Hello, a basic question here:
    Is it possible to create a custom C++ class usable later by an UActor as, let's say, a component?

    I am asking this for reasons like... having a class with multiple inheritance, where this is no possible with Unreal Engine C++ clases.

    Thanks!

    #2
    Hi,

    multiple inheritance with actor-components is doable.
    If you for example search the solution for "public UActorComponent, public" or "public USceneComponent, public", there exist a lot of occurences.


    Cheers,
    Carsten

    Comment


      #3
      So let's say I have C++ classes: A, B, C.

      Can C inherit from A and B and then use C as a Component?

      Comment


        #4
        Components can't have components, so no, C can't have another copy of itself as a component, because that implies C is a component in the first place. But you can do multiple sources of inheritance. Almost always in that case though you need to ask yourself if using an Interface is more appropriate.

        Comment


          #5
          You cannot do multiple inheritance from more than one UObject type, and components can only exist within actors. The following is allowed:

          Code:
          class UMyComponent : public UActorComponent, public ISomeNativeInterface
          {}
          This is *NOT* allowed:

          Code:
          class UMyComponent : public UActorComponent, public USomeOtherUObjectClass
          {}

          Comment

          Working...
          X