Cant get damage AddDynamic to work on component

“Not working” … not compiling, not taking damage, …?

Except for the extra comma, the code is ok. How are you using this component and applying damage?

I made a statComponent to manage the characters and general actor life stats, but I cant get the function to fire when the actor take damage.

This is what the cpp looks like:

// Called when the game starts
void UDNAStatComponent::BeginPlay()
{
	Super::BeginPlay();

	// ...

	AActor* owner = GetOwner();

	if (owner) {
		
		owner->OnTakeAnyDamage.AddDynamic(this, &UDNAStatComponent::TakeDamage);
		UE_LOG(LogTemp, Warning, TEXT("BindedOnTakeAnyDamage with %s"), *owner->GetPathName());

	}
}


void UDNAStatComponent::TakeDamage(AActor* DamagedActor, float Damage, const class UDamageType* DamageType, class AController* InstigatedBy, AActor* DamageCauser)
{



	UE_LOG(LogTemp, Warning, TEXT("Text, %f"), Stat.HealthCurrent);

}

And the .h:

	UFUNCTION(BlueprintCallable,)
		void TakeDamage(AActor* DamagedActor, float Damage, const class UDamageType* DamageType, class AController* InstigatedBy, AActor* DamageCauser);

I have no clue why is it not working.

It doesnt fire the binded function TakeDamage when damaged, everything compiles fine. I am testing all I can think of to find where is the error but no luck.

BP on collision enter or on player input from a c++ function. Yes, several times in case it was the hotreload.

Figured it out, I was using the wrong function to do damage on c. Was using actor->RecieveDamage() instead of actor->TakeDamage().

Program in this absurdly overcomplicated mess of an engine is just a huge waste of time.

This is exactly why people dont give a ■■■■ about the default built in systems in unreal. What a mess ffs.
I was stucked a hole day with this, how do they expect people to get this things with a thousand functions that and no documentation??

Thank you very much EvilCleric. Sorry have wasted your time T_T

Restarted the editor?

Are you causing the damage from BP or from C++?

Your code works, so perhaps you’re using it wrong. Show us:

  • how are you adding the component;
  • how you are triggering it