C++ to Blueprint
We now have a health and health regeneration system in our character class. One problem with our current system is that we have not yet defined what happens to our character after the health reaches 0. In this section, we will create an event that we will implement in Blueprint. This event will be called when the player's health reaches 0.0. To create this Blueprint event, open our character header file and add the following code:
UFUNCTION(BlueprintImplementableEvent, Category = "My Character") void PlayerHealthIsZero();
As you can see, we added a normal function called PlayerHealthIsZero()
. To make this available in Blueprint, we added a UFUNCTION
specifier and inside that we added BlueprintImplementableEvent
. This means C++ can call this function and it will execute inside Blueprint but we cannot add a definition for this in our character source file. Instead, we will just call it inside the source file whenever we want. In this example, we will call it inside our TakeDamage...