Download

Overriding interface method in class inheriting from base class that inherits from interface

So basically I have method in interface, then have some base class that inherits from interface and implements base behaviour for certain type of actors and in the end there is actor itself(Let’s call it NotBase for simplicity).
Methods are implemented with BlueprintNativeEvent property so every definition has _Implementation at the end.
When I try to implement method in NotBase UE4 totally ignores my imlenentation and if there is definition in Base will call it if not won’t call method regardless code in NotBase
My class hierarchy:
Inteface->BaseClass->NotBaseClass

Code example(simplified for clarity)
Interface:

UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "ItemInterface")
    bool ActivateItem();

BaseClass.h:

virtual bool ActivateItem_Implementation() override;

BaseClass.cpp:

bool BaseClass::ActivateItem_Implementation()
{
    UE_LOG(LogTemp, Warning, TEXT("a"));
    return false;
}

NotBase.h

virtual bool ActivateItem_Implementation() override;

NotBase.cpp

bool NotBase::ActivateItem_Implementation()
{
UE_LOG(LogTemp, Warning, TEXT("aa"));
return true;
}

How method is called:

SomeComponent::Method()
{
    NotBaseActor->Execute_ActivateItem(Base* NotBaseActor);
}

In this scenario i never get “aa” in log

Does anyone have an idea if I can do this, or will I have to use an interface without being able to implement it in BP?

Hi,
I Doubled checked this and it is working perfectly for me. I am getting AA if i spawn in childActor.
only thing different is how Execute interface function:
IMyInterface::Execute_MyInterfaceMethod(this);

Though this shouldn’t make any difference but you might have some other problem.

1 Like

Sooo yea I fu**ed up I had BP derived from Base class not from NotBase and that’s why it wasn’t working :sweat_smile:. And btw both ways of calling methods work perfectly fine now.