Couple questions:
- Should we really return the capped damage (i.e. result of
FMath::Min
) as done in the lesson, or the original amount? The parent class said it used that original amount. It doesn’t seem correct to later tell that less was used from the hit.
For that matter, theTakeDamage
function in APawn has a comment saying to not modify the amount after callingSuper::TakeDamage
:
float APawn::TakeDamage(...)
{
...
// do not modify damage parameters after this
const float ActualDamage = Super::TakeDamage(Damage, DamageEvent, EventInstigator, DamageCauser);
...
}
Moreover, AActor
has already broadcast that the original amount was applied:
float AActor::TakeDamage(...)
{
...
ReceivePointDamage(ActualDamage, ...);
OnTakePointDamage.Broadcast(this, ActualDamage, ...);
...
}
- Shouldn’t we apply the damage via
InternalTakePointDamage
instead ofTakeDamage
, that seemed to be the function that actually decides how much of the damage is being applied.
I think it is also necessary to handle layered damages (e.g. energy shield → armor → health), where the function could do something like:
float InternalTakePointDamage(float Damage, ...) {
float MyLayerDamage = FMath::Min(Damage, MyLayerHealth);
MyLayerHealth -= MyLayerDamage;
float LeftOverDamage = Damage - MyLayerDamage;
float InnerLayersDamage = Super::InternalTakePointDamage(LeftOverDamage, ...);
return InnerLayersDamage + MyLayerDamage;
}
- Shouldn’t we use
FMath::Clamp
instead ofFMath::Min
since the amount can be negative? I saw an example, I believe it was the Epic website but I can’t find it again, where health kits work by applying negative damage.