Bugfix Regen Health Whilst Being Taking Damage
This commit is contained in:
parent
dac2f1f708
commit
3721fff015
@ -90,6 +90,7 @@ void AEndlessVendettaCharacter::RegenHealth()
|
|||||||
Heal(10);
|
Heal(10);
|
||||||
if (GetWorld()->GetTimerManager().GetTimerRate(RegenHealthTimerHandle) > 1.0f)
|
if (GetWorld()->GetTimerManager().GetTimerRate(RegenHealthTimerHandle) > 1.0f)
|
||||||
{
|
{
|
||||||
|
GetWorld()->GetTimerManager().ClearTimer(RegenHealthTimerHandle);
|
||||||
GetWorld()->GetTimerManager().SetTimer(RegenHealthTimerHandle, this, &AEndlessVendettaCharacter::RegenHealth, 1.0f, true);
|
GetWorld()->GetTimerManager().SetTimer(RegenHealthTimerHandle, this, &AEndlessVendettaCharacter::RegenHealth, 1.0f, true);
|
||||||
}
|
}
|
||||||
if (CurrentHealth >= MaxHealth) GetWorld()->GetTimerManager().ClearTimer(RegenHealthTimerHandle);
|
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"));
|
UE_LOG(LogTemp, Warning, TEXT("Player is dead"));
|
||||||
UGameplayStatics::OpenLevel(this, FName(*GetWorld()->GetName()), false);
|
UGameplayStatics::OpenLevel(this, FName(*GetWorld()->GetName()), false);
|
||||||
|
|
||||||
return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
|
return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
|
||||||
}
|
}
|
||||||
if (!GetWorld()->GetTimerManager().IsTimerActive(RegenHealthTimerHandle))
|
|
||||||
{
|
GetWorld()->GetTimerManager().ClearTimer(RegenHealthTimerHandle);
|
||||||
GetWorld()->GetTimerManager().ClearTimer(RegenHealthTimerHandle);
|
GetWorld()->GetTimerManager().SetTimer(RegenHealthTimerHandle, this, &AEndlessVendettaCharacter::RegenHealth, 5.0f, true);
|
||||||
GetWorld()->GetTimerManager().SetTimer(RegenHealthTimerHandle, this, &AEndlessVendettaCharacter::RegenHealth, 5.0f, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
|
return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user