I need purely native implementations. Some of them need to be blueprint-callable, but I don’t plan on implementing/overriding anything in blueprints. Some (native) implementations shouldn’t have to be defined in derived classes, I just need a constant base-implementation for them. And that’s the problem: The compiler always produces errors telling me I need to implement functions in derived classes that I don’t want to override.
In my case, I want to have an interface for any actor that can belong to a “faction” (friend, foe…). The only thing that needs to be virtual is an unexposed function that returns a pointer to the “FactionInfo”-data-structure, which every actor-class that implements the interface has as a member. Everything else should be done by non-virtual interface functions that use the virtual GetFactionInfo() to obtain the data.
Am I missing a function specifier here? Are base-implementations not supported for interfaces?..
I am facing the same problem, now, trying to add a default implementation so I can have a default behaviour and not be forced to implement the interface function in all of my blueprints that implements the interface.
Did you manage to find an answer and eventually a way around this limitation ?
It’s been too long to give you a reliable answer, but iirc you can only have default implementations and non-virtual functions in interfaces when you don’t expose them with any blueprint related specifiers. It should be possible to mix non-exposed and exposed functions in the same interface and call strictly native code from blueprint compatible functions though, so you only have to implement that function call in every interface implementation that can’t use a default by itself. I hope that’s right… Like I said, it’s been a while.
thanks for your reply,
The default behaviour I wanted was to return the passed parameter (while some specific implementation would return it modified), so my way around was to test the return value and if it seemed unitialized I would just ignore it.
UE4 reflection system and mostlikely blueprint virtual machine don’t support default implementation, but C++ it self should support it as C++ don’t formally support interfaces, but multi parenting so for C++ they fully functional classes. UHT will ignore nonreflected functions so you can os whatever you want on C++ side.
In 5.2, I can provide a c++ default implementation in the interface, but it’s considered a pure function, and cannot access this pointer. So I can’t do much in there. How did u get the instance of the object implementin the interface?