I am having a problem trying to call a method on an interface from c++ to invoke and overridden function in a blueprint class.
- Define interface in C++; IHelp with one method named bool Test()
- Define actor in C++; Foo that inherits IHelp
- Derive blueprint actor from Foo; Boo
- Override bool Test() as a function in Boo
- I add Boo to the level and then call a function Library method which invokes IHelp → Test() on Boo. the function library is written in C++.
does implement the interface
without any problem executes
But … the overridden function never gets called?
I have tried everything with no success.
I think this post describe the problem I’m having, but I have tried all of the tips and it still does not work.
Any advice would be appreciated!
You need to call your function with Execute_ prefix which will call blueprint if function id overrided so
Execute_Test(). It’s a function generated by UHT.
Hi Shadow, I was doing that. I’m going to redo the class do a simple test example and try it again. I will post the code and results. much appreciated you hanging in there and trying to help me.
It works! I honestly think I must be losing my mind because I tried this so many times doing the exact same thing and it never worked before. For the sake of being complete and documenting the solution for others who may be struggling here is my code . thanks again shadow!
// This class does not need to be modified.
class ULockable : public UInterface
class EMBER_API ILockable
// Add interface functions to this class. This is the class that will be inherited to implement this interface.
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable, Category = "Lockable")
void Lock(const FString &key);
class EMBER_API ALockingActor : public AActor, public ILockable
// Sets default values for this actor's properties
// Called when the game starts or when spawned
virtual void BeginPlay() override;
// Called every frame
virtual void Tick(float DeltaTime) override;
FString key = FString();
bool isLocked = false;
void UFunctionLibrary::TestLock(AActor * actor)
FGuid guid = FGuid::NewGuid();
Create a blueprint based on locking actor, and then implement the Event Lock.
When you call the Execute_Lock function in your C++ Code the blueprint event will be called.