Bugfix Regen Health Whilst Being Taking Damage

This commit is contained in:
Philip W 2023-11-09 13:13:41 +00:00
parent dac2f1f708
commit 3721fff015

View File

@ -90,6 +90,7 @@ void AEndlessVendettaCharacter::RegenHealth()
Heal(10);
if (GetWorld()->GetTimerManager().GetTimerRate(RegenHealthTimerHandle) > 1.0f)
{
GetWorld()->GetTimerManager().ClearTimer(RegenHealthTimerHandle);
GetWorld()->GetTimerManager().SetTimer(RegenHealthTimerHandle, this, &AEndlessVendettaCharacter::RegenHealth, 1.0f, true);
}
if (CurrentHealth >= MaxHealth) GetWorld()->GetTimerManager().ClearTimer(RegenHealthTimerHandle);
@ -207,11 +208,9 @@ float AEndlessVendettaCharacter::TakeDamage(const float DamageAmount, FDamageEve
return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
}
if (!GetWorld()->GetTimerManager().IsTimerActive(RegenHealthTimerHandle))
{
GetWorld()->GetTimerManager().ClearTimer(RegenHealthTimerHandle);
GetWorld()->GetTimerManager().SetTimer(RegenHealthTimerHandle, this, &AEndlessVendettaCharacter::RegenHealth, 5.0f, true);
}
GetWorld()->GetTimerManager().ClearTimer(RegenHealthTimerHandle);
GetWorld()->GetTimerManager().SetTimer(RegenHealthTimerHandle, this, &AEndlessVendettaCharacter::RegenHealth, 5.0f, true);
return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
}