Download

Virtual inheritance

Hi!
Is virtual inheritance possible in UE4? I’ve tried to virtually inherit some class from another class, and I’m getting this message:


Info Class names must match Unreal prefix specifications (e.g., "UObject" or "AActor")
CollectableItem.h(1) : Error: No prefix or invalid identifier for base class virtual.


The code in question is this:


UCLASS(Blueprintable)
class ACollectableItem
    : public virtual AItem
    , public ICollectable_Interface
{
    GENERATED_BODY()

    public:
        virtual void OnCollect() override;
};

Turns out this is not possible. Well, time for me to refactor then.
As a side note, how would you guys implement (UE4 specific) a class of Items, some of which can be Interacted() with, some can be Collected(), and some can be both Interacted() and Collected(). Since MI is not possible in UE4 if you require UObject functionality from multiple parents, AND I’d like to avoid storing bitfields or boolean values to represent if an object is Interactable or Collectable, what is the most future-proof solution to this problem in UE4?

The solution in UE4 is to either use Interfaces or Actor Components.

If you want to avoid storing bools, just create two interfaces (ICollectable and IInteractable)

The problem here is that the “override” keyword has been specified but none of the base classes have a virtual function matching the same signature.