Hello,
I have almost null experience in Unreal C++ programming, just in Blueprints. Ive been struggling to implement a Interface Class within C++, even after following some written tutorials over the forums, answerhub, blogs, I feel I didn
t understand correctly how to write this.
So, my goal is to make a WeaponFireInterface class, which has a void RequestPrimaryFire() method
Heres what I
ve done so far inside the WeaponFireInterface.h
#pragma once
#include "Object.h"
#include "WeaponFireInterface.generated.h"
/**
*
*/
UINTERFACE(Blueprintable)
class DEMOROOM1_1_API UWeaponFireInterface : public UInterface
{
GENERATED_UINTERFACE_BODY()
};
class IWeaponFireInterface
{
GENERATED_IINTERFACE_BODY()
public:
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "RequestFire")
void RequestPrimaryFire();
};
Ok, everything ordinary so far.
Inside my Weapon class, I`ve added this:
UCLASS()
class DEMOROOM1_1_API AWeapon : public AActor, public IWeaponFireInterface
{
GENERATED_BODY()
and
//INTERFACES
void RequestPrimaryFire();
When hit build, the error message is: F:\UnrealProjects_SourceControl\Demoroom_1.1 4.12\Source\Demoroom1_1\Weapon.h(88): error C2259: ‘AWeapon’: cannot instantiate abstract class
I’m sure I did not understand correctly how Interfaces are implemented in the Engine’s framework.
Another thing it complains is when I add virtual to the method, inside the Interface class.
Thanks in advance.