Improve C++ 'Interface' Workflow.

Hi there, I’m an indie dev that’s been looking into UE4 for future dev projects! I had a bit of experience with UDK in the past, but I’ve only recently taken a serious stab at coding in Unreal Engine since UE4. There are many things I like about UE4, but theres something that really bothers me so far: C++ ‘Interfaces’ seem difficult to implement and the workarounds that I’ve found online are convoluted. Here’s what I mean:

Generally when I code I like to use ‘interfaces’ (in C++, purely abstract/virtual classes) to tie unrelated-yet-similar classes together. In pure C++ it’s as easy as this:


class IDamageable
{
public:
    virtual ~IDamageable() {}
    virtual void Damage() = 0;
}


class Car : public Vehicle, public IDamageable
{
public:
    virtual void Damage()
    {
        //Do something to damage a vehicle...
    }
}


class Shield : public Equipment, public IDamageable
{
public:
    virtual void Damage()
    {
        //Do something to damage a shield...
    }
}

In this way you can have various unrelated classes extend IDamageable, or IKickable, ISaveable, or ILickable without needed to find some way to wrangle a new intermediate parent class into the mix. From my limited experience with UE4 so far, it seems that this paradigm isn’t as straight forward as it should be. I found some official information here:

I had trouble getting this to work and I’m assuming this section of documentation is either out of date or just incomplete. Merely switching the UCLASS() macro to UINTERFACE() doesn’t seem to work well when you want to add an interface to an Actor or ActorComponent subclass… I kept looking for more info, and I eventually found this:

https://wiki.unrealengine.com/Interfaces_in_C%2B%2B

I was eventually about to create an interface that worked as a regular function would and even had the ability to expose it to Blueprints as a BlueprintImplementableEvent, but the solution was messy and felt like a convoluted workaround. I’d love to see interfaces treated like creating other new C++ classes, where you can just go; “Create a new C++ Class -> Extend from Interface -> Name your new interface -> Open IDE and add functions!”. But, as of now, UInterface doesn’t even show up in my list of classes to extend from (even when I tick the box that’s supposed to show me more parent classes), and it’s very unclear from the documentation what the proper way to write a new C++ interface is. Maybe I was just doing it wrong or over thinking it, or maybe I just missed something because I’m still new to UE4, but from what I can tell the C++ ‘interface’ situation just sucks right now and it seems like i’d just be better off avoiding them all together…