Hello, comrades!
Sorry for my english, but i’ll try to explain what i want to do.
So, i have inteface in C++:
#pragma once
#include "Interface.h"
#include "IPickupItem.generated.h"
UINTERFACE(Blueprintable)
class MYGAME_API UPickupItem : public UInterface
{
GENERATED_BODY()
};
class MYGAME_API IPickupItem
{
GENERATED_BODY()
public: // this methods must be implemented only through Blueprints
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "My|InterfaceMethods")
void PickupItem(USceneComponent* AttachTo);
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "My|InterfaceMethods")
void DropItem();
};
C++ class, which inherits from interface:
#include "IPickupItem.h" // my interface
#include "ItemBase.generated.h"
UCLASS()
class MYGAME_API AItemBase : public AActor, public IPickupItem
{
GENERATED_BODY()
public:
AItemBase(); .... // (some other stuff, methods, members, etc. don't really matters)
// BUT! I don't have any overload or overrides of interface methods!
protected:
UPROPERTY(Category = "My|Basic", EditAnywhere, BlueprintReadWrite)
UMeshComponent* itemMesh; // will be inited in child class!
}
And i have child class of game item, for example:
#pragma once
#include "CoreMinimal.h"
#include "ItemBase.h"
#include "StaticItemBase.generated.h"
UCLASS()
class MYGAME_API AStaticItemBase : public AItemBase
{
GENERATED_BODY()
public:
AStaticItemBase(); // initializes itemMesh from AItemBase with StaticMeshComponent
UFUNCTION(BlueprintCallable, Category = "My|Methods")
UStaticMeshComponent* GetStaticMesh(); // returns itemMesh' pointer
protected:
};
Then i’am creating a Blueprint from my AItemBase (ItemBase_BP) class and another one - from AStaticItemBase (StaticItemBase_BP). Some instances of StaticItemBase_BP are placed to game map to interract with.
What was my idea: in ItemBase_BP i make implementation of interface methods PickupItem() and DropItem(), that will be called from MotionController BP (standart from VR-sample) using interface call when i’am trying to pick up an object StaticItemBase_BP with motion controller.
All checks like “is overlapping objects implements my interface” are correct and works fine.
Problem is, that execution never comes to ItemBase_BP event PickupItem()/DropItem() for StaticItemBase_BP objects. I think that’s because they (objects) are not directly inherited from ItemBase_BP.
ItemBase_BP is inherited from AItemBase C++ class (and C++ interface), StaticItemBase_BP is inherited from AStaticItemBase C++ class (which is inherited from AItemBase C++ class =)).
Please, can someone explain me, how this can be solved? I mean, is there any way to call Blueprint implementation of base class interface function for ALL child objects, which are inherited from that base class?
Thank you!
Alex