Overloading interface functions

I was creating an interface and wanted to add convenience functions:

UFUNCTION(BlueprintNativeEvent, Category = Actor)
void SetActive(bool active);

UFUNCTION(BlueprintNativeEvent, Category = Actor)
void SetActive(); // Calling SetActive(true);

There was no way to compile this as the overloaded function was not recognized.

In the derived class:

virtual void SetActive_Implementation() override;

Gives the error:

SetActive_Implementation’: method with override specifier ‘override’ did not override any base class methods

A simple renaming of the function solved the problem, which leads me to believe you can not overload functions in interfaces because the code Unreal uses behind the scenes to expose to blueprints and makes them able to override breaks C++.

Correct. You can not have two UFUNCTIONs with the same name in the same class.

you can use meta=(DisplayName="function name") for custom display name in the blueprint editor.

In case of event, you don’t need to use “UFUNCTION” on 2nd event, it will work in C++ and if event is used in blueprint it will have default pin value anyway

You could also use a default value: void SetActive(optional bool active = true); according to this LINK

I’m not sure how this node is displayed in the blueprint editor but in c++ you should just be able to call SetActive().

Well, I was not able to compile this, so you cant call it from C++ nor see it in the blueprint.

I just thought it would be nice if C++ completely worked with Unreal, but there are so many C++ things that just fail terribly because of all the weird **** Unreal is doing behind the scenes. I would even say what I am programming in is not really C++, its more like UC++ or something.

Same I had as I used the new operator to create something and it just blew up my whole game because I am not allowed to use “new” with Unreal.

Maybe it is time to clean up the C++ part of Unreal a bit and streamline the whole blueprint integration, I think most of the problems Unreal has with standard C++ come from blueprint weirdness.