#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "UObject/Interface.h"
#include "BetterKillerInterface.generated.h"
/**
*
*/
UINTERFACE(MinimalAPI)
class UBetterKillerInterface : public UInterface
{
GENERATED_BODY()
};
class AIVPROGRAMMAZIONE3_API IBetterKillerInterface
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
void Shot();
UFUNCTION(BlueprintCallable, BlueprintNativeEvent)
void Kill();
};
Now both the Blueprint Classes as well as the C++ ones can inherit from it (Blueprint interfaces can be set from the class settings panel in the blueprint editor)
class FooBar : public AActor, public IBetterKillerInterface
{
};
if (FoundActor->GetClass()->ImplementsInterface(UBetterKillerInterface::StaticClass()))
{
IBetterKillerInterface::Execute_Kill(FoundActor);
}
Note that you need to call the static method generated with the Execute_ prefix passing the this/context/owner as the first argument