I am trying to make an ActorComponent with CPP called HealthComponent that stores current health, max health, has a function to decrease health and calls an event when the health reaches zero. So far everything has went smoothly, but I cannot no matter what I do get an event node to show up in the blueprint editor. The way I want to set it up is that the component is added into a actor and then the implementation can be made in the blueprint editor. I have tried everything, scoured the internet and nothing worked. I tried using BlueprintNativeEvent event macro, using BlueprintImplementableEvent event macro, using Blueprintable ActorComponent class macro, it didnt work, I tried refreshing, recompiling, making a new blueprint, restarting my computer, nothing works please help, here is my code, I am using rider v2025.1.2, UE5.5.4
// HealthComponent.h
#pragma once
#include "CoreMinimal.h"
#include "Components/ActorComponent.h"
#include "HealthComponent.generated.h"
UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent), Blueprintable )
class RIDERPROJECT_API UHealthComponent : public UActorComponent
{
GENERATED_BODY()
public:
// Sets default values for this component's properties
UHealthComponent();
protected:
// Called when the game starts
virtual void BeginPlay() override;
public:
// Called every frame
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
// Health variables
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Health")
int MaxHealth = 100.f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Health")
int CurrentHealth;
// Function to decrease health
UFUNCTION(BlueprintCallable, Category = "Health")
void DecreaseHealth();
UFUNCTION(BlueprintCallable, BlueprintImplementableEvent, Category = "CustomEvents")
void OnHealthDepleted();
};
// HealthComponent.cpp
#include "HealthComponent.h"
#include "RiderProject/Public/HealthComponent.h"
// Sets default values for this component's properties
UHealthComponent::UHealthComponent()
{
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features
// off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true;
// ...
}
// Called when the game starts
void UHealthComponent::BeginPlay()
{
Super::BeginPlay();
// ...
CurrentHealth = MaxHealth;
}
// Called every frame
void UHealthComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
// ...
}
void UHealthComponent::DecreaseHealth()
{
CurrentHealth -= 1;
if (CurrentHealth == 0)
{
OnHealthDepleted();
}
}