diff --git a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp index 1c677f82..98db3135 100644 --- a/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp +++ b/EndlessVendetta/Source/EndlessVendetta/EndlessVendettaCharacter.cpp @@ -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); @@ -204,14 +205,12 @@ float AEndlessVendettaCharacter::TakeDamage(const float DamageAmount, FDamageEve } UE_LOG(LogTemp, Warning, TEXT("Player is dead")); UGameplayStatics::OpenLevel(this, FName(*GetWorld()->GetName()), false); - + 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); }