[SOLVED]
I’ve been trying for some hours to make a simple interface class work, without success.
My goal is to implement a Interface Class for my weapon(WeaponFireInterface) with a single method: virtual void RequestPrimaryFire();
The method should be called by blueprints, and overridable by a C++ class.
I can’t make it work using this setup inside my method:
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = “RequestFire”)
virtual void RequestPrimaryFire();
It seems that BlueprintNativeEvent prevents the method to be virtual.
Error msg :2> F:/UnrealProjects/_SourceControl/Demoroom_1.1 4.12/Source/Demoroom1_1/WeaponFireInterface.h(23) : BlueprintImplementableEvents in Interfaces must not be declared ‘virtual’
So, here’s my code:
WeaponFireInterface
.h
UINTERFACE(Blueprintable)
class DEMOROOM1_1_API UWeaponFireInterface : public UInterface
{
GENERATED_UINTERFACE_BODY()
};
class IWeaponFireInterface
{
GENERATED_IINTERFACE_BODY()
public:
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RequestFire")
virtual void RequestPrimaryFire();
}
.cpp
void IWeaponFireInterface::RequestPrimaryFire_Implementation()
{
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Green, TEXT("Interface method original call"));
}
Weapon class
.h
class DEMOROOM1_1_API AWeapon : public AActor, public IWeaponFireInterface
{
GENERATED_BODY()
...
//INTERFACES
virtual void RequestPrimaryFire();
.cpp
void AWeapon::RequestPrimaryFire()
{
GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Blue, TEXT("Interface method overriden"));
}
Need some help to make this overridable in C++ and be called by Blueprints, too.
Thanks in advance