How to damage a destructible using C++?

After completing the FPS C++ tutorial I started playing around and wanted to let the projectiles shatter stuff in AFPSProjectile::OnHit(..)
My targets are from type ADestructibleActor and shatter when falling, damage threshold is set to 1.0f, but I get only my debug message on screen. Here is the code:

void AFPSProjectile::OnHit(class AActor* OtherActor, ..)
{
	// snip
	ADestructibleActor* pDestructible(Cast<ADestructibleActor>(OtherActor));
	if (pDestructible)
	{
			GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, "Hit destructible");
			FDamageEvent damageEvent;
			pDestructible->TakeDamage(10.0f, damageEvent, _pController, this);
	}
}

_pController is set to the AFPSCharacter.Controller after spawning the projectile.

Has someone any idea what I am missing/doing wrong?

#Solution

pDestructible->DestructibleComponent->ApplyDamage

or

pDestructible->DestructibleComponent->ApplyRadiusDamage

/*
UFUNCTION(BlueprintCallable, Category=Destruction)
	void ApplyDamage(float DamageAmount, const FVector& HitLocation, const FVector& ImpulseDir, float ImpulseStrength);

	// Take radius damage
	UFUNCTION(BlueprintCallable, Category=Destruction)
	void ApplyRadiusDamage(float BaseDamage, const FVector& HurtOrigin, float DamageRadius, float ImpulseStrength, bool bFullDamage);

*/

Works like a charm, thank you very much :slight_smile: