How do I create a Custom Event in C++?

Hi! Sorry to hear you’re having trouble with this -

Are you trying to do BlueprintImplementableEvent or BlueprintNativeEvent? The first one will only have behavior written in Blueprints, but the second one can also have C++ behavior.

If you want a BlueprintImplementableEvent, just have these lines in your header file - and then no C++ code in your .cpp file.

UFUNCTION(BlueprintImplementableEvent, Category = "DmgSystem")
void TakeDmg(int32 Damage);

If you want a BlueprintNativeEvent, with some functionality in C++ and some functionality adding on or overriding in Blueprints, have these lines in your header file:

UFUNCTION(BlueprintNativeEvent, Category = "DmgSystem")
void TakeDmg(int32 Damage);

And then these lines in your source file:

void TakeDmg_Implementation(int32 Damage)
{
   // your code here
}

Also, if you were getting errors about not being able to call functions externally, make sure that your TakeDmg function declaration is not below a “protected” or “private” line in the Character’s header file.

BlueprintImplementable and BlueprintNative events are both meant to be called from C++, so what you may want to do for your functionality is have two functions. One is BlueprintCallable, and has a C++ definition that calls your BlueprintImplementable or BlueprintNative events. The other is your actual TakeDmg event. I’ll take a quick look and see if that would do what you’re trying to accomplish. :slight_smile:

If you’d like, attach your Character header and source files here and we can take a look!