After EXTENSIVE research on this matter I finally solved it, though it was far form easy and there still exists some excentricities. Twiddle was not far off, but there was a gap in my own knowledge that was answered by pure luck of me discovering an Unreal Engine Interface that I could hook into through blueprints. After spelunking through the engine code I found the key to this riddle in the IGameplayTagAssetInterface found under the Runtime/GameplayTags/Classes folder.
So This solution is specifically well suited if you have multiple objects utilizing a different base object. In my case the interface will be applied to AActor types and ACharacter types, both share the AActor as a base class which allows my interface to pass round AActor types and InterfaceCast them to the proper interfaces in the implemented of the functions.
MyInterface.h
UINTERFACE(Blueprintable, meta=(CannotImplementInterfaceInBlueprint))
class UMyInterface : public UInterface
{
GENERATED_UINTERFACE_BODY()
};
class MYGAME_API IMyInterface
{
GENERATED_IINTERFACE_BODY();
UFUNCTION(BlueprintCallable, Category = "My Interface")
virtual AActor * GetSomeActor();
UFUNCTION(BlueprintCallable, Category="My Interface")
virtual bool SomeTestFunction(bool IsSomething);
}
MyInterface.cpp
/// Interface constructor here stuff ...
AActor * IMyInterface::GetSomeActor()
{
unimplemented();
return NULL;
}
bool SomeTestFunction(bool IsSomething)
{
unimplemented();
return false;
}
MyActor.h
class AMyActor : public AActor, public MyInterface
{
UFUNCTION(BlueprintCallable, Category = "My Interface")
virtual AActor * GetSomeActor() override;
UFUNCTION(BlueprintCallable, Category="My Interface")
virtual bool SomeTestFunction(bool IsSomething) override;
};
MyActor.cpp
AActor * MyActor::GetSomeActor()
{
AActor * returnActor = NULL;
// Some code here to do things and get an actor and set returnActor
return returnActor;
}
bool MyActor::SomeTestFunction(bool IsSomething)
{
bool returnBoolean = false;
// do some stuff and test some stuff set returnBoolean
return returnBoolean;
}
You can pretty much do anything you want with this setup except the major drawback is that this interface CANNOT be implemented in blueprints. It just so happends that my solution does not need that at the level I am working with. However if you want to overcome that drawback I suggest trying to build a second interface that can be blueprint implementable that is called by your non-blueprint implementable interface
So you’d have MyInterface and MyImplementableInterface that has functions and events that are called from MyInterface (at least from the implementing class).
So now that you have this interface built, your base classes will implement the interface and then from blueprints you will need to call functions from it. In blueprints this is a bit different than I had expected but it works none-the-less. In any blueprint right click (without having any line drawn out) and look for a category called “Interface Messages”. This is where you interfaces functions will be kept under what ever category you gave them.
Below is a screen show of how that will look with a few annotations.
Basically these “Interface Messages” take as the first parameter any object in the game and attempts to cast and call the function from that “target” object. If it fails it does so silently, if it succeeds then all is good. I suggest prefixing any one of these calls with a “Implements Interface” node in case you have any thing down the chain of events that require that that object actually implement the interface.
I hope this helps anyone else out there.