Add max health check to `SetCurrentHealth`

This commit is contained in:
Louis Hobbs 2023-01-13 21:14:08 +00:00
parent a90c447ce9
commit 4712d405d5
1 changed files with 5 additions and 1 deletions

View File

@ -57,8 +57,12 @@ float UHealthComponent::GetCurrentHealth()
void UHealthComponent::SetCurrentHealth(float value) void UHealthComponent::SetCurrentHealth(float value)
{ {
// TODO: We might want to add some extra checking here
CurrentHealth = value; CurrentHealth = value;
if (CurrentHealth > MaxHealth)
{
CurrentHealth = MaxHealth;
}
} }
void UHealthComponent::ResetHealth() void UHealthComponent::ResetHealth()