BlueprintImplementableEvent is preventing project from compiling

UFUNCTION(BlueprintImplementableEvent, Category = Power)
void PowerChangeEffect();

The above code causes the following error;

1> [4/4] Link UE4Editor-BatteryCollector-8718.dll
1>BatteryCollector.generated.cpp.obj : error LNK2005: “public: void __cdecl ABatteryCollectorCharacter::PowerChangeEffect(void)” (?PowerChangeEffect@ABatteryCollectorCharacter@@QEAAXXZ) already defined in BatteryCollectorCharacter.cpp.obj

Comment out the UFUNCTION and the project compiles fine. Any help appreciated.

1 Like

Try the following steps.

  1. Uncomment the UFUNCTION
  2. Close the editor
  3. Delete the Intermediate/Build folder
  4. Delete the Binaries folder
  5. Do Build->Rebuild from VS

Hi CoCopia,

Judging from that error, it looks like you have most likely created a definition of the void ABatteryCollectorCharacter::PowerChargeEffect() function in your BatteryCollectorCharacter.cpp file. Is this correct?

If so, you’ll probably want to either remove this definition or use the BlueprintNativeEvent keyword instead. Here’s why:

The BlueprintImplementableEvent keyword is designed for functions that have no common implementation in your base class – only the specific Blueprints will know what to do when the function is called. Thus, the engine expects there to be no function definition (in your *.cpp file) for functions that are declared as BlueprintImplementableEvent’s. You’ll only get to run code from the actual Blueprints for these events.

The BlueprintNativeEvent, on the other hand, is designed for functions that have some common basic implementation in your base class but that will need more or different behavior in some/all of the Blueprints. For BlueprintNativeEvents, you’ll need to declare an implementation function in your *.h file (ex: virtual void PowerChargeEffect_Implementation();, in your case) and then define it in your *.cpp file (ex: void ABatteryCollectorCharacter::PowerChargeEffect_Implementation() { /* Your code goes here */ }). The Blueprints will then be able to override or extend that implementation on their own to create different or additional effects. With these events, you’ll be able to run code from Blueprints in addition to or instead of the default code from your C++ class.

Does this help at all?

1 Like

Thank you, a light bulb went off in my head after reading your answer, of course there shouldn’t be a definition in the .cpp file, explains the error of multiple symbols, which was really throwing me.

Thanks for your help, I have tried these but to no avail however the answer below from Roomon solved the problem

After 1 hour finally find this solution thank you