How to send interface message using c++?

I have an interface. This interface is made as c++ class, but the functions inside will be implemented by blueprints.(Same interface, differently implemented in each other actors.)

I need to send interface messages to other actors, or even to myself by c++ in order to call the function implemented. I searched for tutorials or epic games documents but all I found was just fully c++ implemented or fully blueprint implemented interfaces.

Is there any example for sending interface messages to other actors or calling the interface function using other actors’ references? The interface function must be implemented by blueprints.

You just have to cast the object that implements the interface, to the interface.

Interface ISomeInterface

Class SomeClass1 : ISomeInterface
Class SomeClass2: ISomeInterface

Instead of casting to SomeClass1 or SomeClass2, you cast your object to ISomeInterface and call the function on that.

For blueprint implementable interface functions, use the Execute_ prefix method instead.

if (Obj->Implements<USomeInterface>())
{
    ISomeInterface::Execute_SomeFunction(Obj /*, arguments*/);
}
1 Like