I am getting error C2535 (“member function already defined or declared”) when trying to declare a blueprint native event on my Character script. It works perfectly fine if I declare the implementation function by itself, however adding the actual event and the UFUNCTION macro will cause me to get this error. Any ideas why this could be? I am using the same syntax, which already worked for me on other scripts.
UFUNCTION(BlueprintNativeEvent, Category = "Character")
void Interact();
virtual void Interact_Implementation();
Are you trying to implement “Interact” in your source file? If so, that would be the cause of your error.
It would help to know which line the error occurs on, and to see the rest of the file before that point.
That because when you place BlueprintNativeEvent, UHT will automatically generate deceleration of _Implementation function by it self, thats why you getting “already declared” error. It’s doing that because 1. It needs that function to be declared for compiler to build generated code 2. So you don’t need to declare it when you don’t need it, other wise you would get undenefied function errors, forcing you to declare it . Just place function definition in cpp file and thats it.
Remember that UHT generated code for you function and paste via GENERATED_BODY() macro
Thank you for your reply - I am sure you are right, unfortunately at this point I have no idea of telling because I just ended up using BlueprintImplementableEvent instead. I do find it weird that for other actors, using it the way I did was perfectly fine…
For future reference to others caught by this trap
If you use on your class GENERATED_UCLASS_BODY()
Then the UHT automatically generates the virtual function declaration, so you can not write another one on the same .h file.
I ended changing the GENERATED_UCLASS_BODY (which is legacy) for GENERATED_BODY and everything compiles again.