Hey all,
I’ve been using interfaces with increasing frequency as a way to reduce dependency and downcasting, and although there are definitely some quirks and limitations you have to keep in mind if you want them exposed to BP, I think they work pretty well for the most part.
However I’ve run into a small issue in regards to method naming with interfaces - here’s the context:
I have an interface, IPlayerDataProvider. It contains accessors for all kinds of player-related data and can realistically go on anything that relates to a specific player. Pawns, abilities, items, targeting actors, whatever.
All methods are BlueprintNativeEvent, and BlueprintCallable so that they can be implemented and called from BP.
Many methods have default implementations in the interface’s .cpp, and some default implementations call other methods in the same interface.
But if I implement
AController* IPlayerDataProvider::GetController()
method on my Character, the Unreal Header Tool seems to get real confused with the one on the base Pawn class when compiling.
Implementation of function 'Pawn::GetController' must be declared as 'event' to match declaration in interface 'PlayerDataProvider'
Now obviously I don’t want to mess with the one on Pawn, but I do want both to coexist the same way you can inherit from 2 interfaces that share method names in vanilla c++.
What’s the workaround here? Renaming a method on the interface because something can’t implement it seems a little bit backward.
It would be a real shame if we had to predictively avoid naming methods the same as any other method on every class and parent class of anything you might ever want to implement the interface on.