Hello. Im trying to apply radial damage but its no doing any damage. Everything working in the function in which im using radial damage. Just so you know, i do have take any damage in my player class and point damage is already working but now i’ve included radial damage and its not working(no damage).
I tried exact same thing that you suggested and still nothing no UE_LOG. So here is what exactly im doing. I have an actor component which im using as a health cmoponent.
This is the actor component code:
USHealthComponent::USHealthComponent()
{
// 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;
DefaultHealth = 100;
SetIsReplicated(true);
}
// Called when the game starts
void USHealthComponent::BeginPlay()
{
Super::BeginPlay();
if (GetOwnerRole() == ROLE_Authority)
{
AActor* MyOwner = GetOwner();
if (MyOwner)
{
MyOwner->OnTakeAnyDamage.AddDynamic(this, &USHealthComponent::HandleTakeAnyDamage);
}
}
Health = DefaultHealth;
}
void USHealthComponent::HandleTakeAnyDamage(AActor* DamagedActor, float Damage, const class UDamageType* DamageType, class AController* InstigatedBy, AActor* DamageCauser)
{
if (Damage <= 0.0f)
{
return;
}
Health = FMath::Clamp(Health - Damage, 0.0f, DefaultHealth);
UE_LOG(LogTemp, Warning, TEXT("Health is %s"), *FString::SanitizeFloat(Health))
OnHealthChanged.Broadcast(this, Health, Damage, DamageType, InstigatedBy, DamageCauser);
}
As you can see i also also have DECLARE_DYNAMIC_MULTICAST_DELEGATE in actor component which has 2 additional parameters. Now in my Player class im binding that broadcast in BeginPlay().
Here is the player class code of bind function:
void ASCharacter::OnHealthChanged(USHealthComponent* OwningHealthComp, float Health, const class UDamageType* DamageType, class AController* InstigatedBy, AActor* DamageCauser)
{
if (Health <= 0.0f && !bDied)
{
bDied = true;
GetMovementComponent()->StopMovementImmediately();
GetCapsuleComponent()->SetCollisionEnabled(ECollisionEnabled::NoCollision);
DetachFromControllerPendingDestroy();
SetLifeSpan(10.0f);
}
}
This is the code im using and point damage does work with this but not radial. As i mentioned in the start, i tried adding OnTakeRadialDamage in Player class separately but still not receiving.