Overriding a Interface method

BattleInterface.h :

UINTERFACE(MinimalAPI)
class UBattleInterface : public UInterface
{
	GENERATED_BODY()
};

class BOSSFIGHTTEST_API IBattleInterface
{
	GENERATED_BODY()

public:

	UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
	void BattleAttack(IBattleInterface* attacker, IBattleInterface* depender, int32 damage);

	UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
	void BattleTakeDamage(int32 damage);
};

MyPlayerState.h :

UCLASS()
class BOSSFIGHTTEST_API AMyPlayerState : public APlayerState, public IBattleInterface
{
	GENERATED_BODY()

public:
	AMyPlayerState() { HP = 100; };

public :
	UPROPERTY(BlueprintReadWrite)
	int32 HP;
	
	void BattleAttack_Implementation(IBattleInterface* attacker, IBattleInterface* depender, int32 damage) override;
	void BattleTakeDamage_Implementation(int32 damage) override;
};

It says ā€˜override’ did not override any base class methods.
Perhaps the parameters of the ā€˜BattleAttack’ method are the cause.
The error only appears in ā€˜BattleAttack’ and not in ā€˜BattleTakekDamgage’

If I delete ā€˜BattleAttack’ or change its parameters, everything is fine.

Hi @Woolzam,

Welcome to the Unreal Engine Forums.

I think the issue may be with the BattleAttack implementation. Unreal Engine doesn’t allow interface functions to have interface pointers (IBattleInterface* attacker) as a parameter. Maybe using a UObject pointer would be a better option here?

Hope this helps.

I’m not terribly versed in c++ enough to tell you literally anything honestly unless its super basic almost hello world type stuff

But looking at this documentation the overrides in the example Trap.h seems to be setup differently
probably something along the lines of what @SylarAtomic said while i was thinking this up

you figure it out please let us know things like this help me to slowly learn it for when i take the deep dive

1 Like
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
void BattleAttack(TScriptInterface<IBattleInterface> attacker, TScriptInterface<IBattleInterface> depender, int32 damage);

I tried ā€˜TScriptInterface’ while this post was pending, but still get the same error.

When I searched for ā€˜LyraStarterGame’, I could find BlueprintNativeEvent functions and a function using ā€˜TScriptInterface’ parameter, but I couldn’t find a function that uses both.

My expectation from using the interface is to create some kind of combat system between different classes: monsters, NPCs, players, etc.