I’ve got a use-case where I want to check if an actor has implemented a blueprint interface and then call an interface method if they have from my C++ code. Anyone got any leads on how to do such a thing?
I specifically don’t want to have to cast actors to base types in this process, so I really want to do what in blueprint would be a “does implement interface” node and then a “call function” node.
That would only work for C++ interfaces though. I’m talking about blueprint interfaces. I need the equivalent of “Does implement interface” and some method of calling the interface function if the object does implement the interface. The point here is to not have to know the class of the thing implementing the functionality.
Is this definitely the case?
When I was experimenting with interfaces not long ago, it seemed there were some limitations, in that Cast<> would only work if the object was of a blueprint derived from a C++ class which itself implemented the interface. If the interface was only implemented at the blueprint level (ie. the parent C++ class of the blueprint didn’t implement the interface), Cast<> would return a null pointer.
There was a workaround for calling interface methods but it was very nasty, and did not actually allow getting an interface pointer to the object.
This is exactly what I needed, thanks! My goal was to find out if a Blueprint (AnimBlueprint in my case) implemented a C++ Interface.
If you don’t want to include the UKismetSystemLibrary, what the function does is, it checks whether the given Interface StaticClass is actually an Interface and then it calls: