L187. Not using Super:: in TakeDamage()?

Why aren’t we using Super:: in Tank.cpp when we’re overriding the TakeDamage() function?

float ATank::TakeDamage(float DamageAmount, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, AActor* DamageCauser)
{
	int32 DamagePoints = FPlatformMath::RoundToInt(DamageAmount);
	int32 DamageToApply = FMath::Clamp(DamagePoints, 0, CurrentHealth);
	CurrentHealth -= DamageToApply;
	if (CurrentHealth <= 0)
	{ OnDeath.Broadcast(); }
	return DamageToApply;
}

Because we want to completely override the function, not extend it by calling the parent class’ function.

1 Like

But aren’t we interested in the original functionality of TakeDamage? We want the damage to go through, and then to do all our custom stuff.

For the purpose of this section that is our code. So we’re completely overriding it.

Is this why, wherever the tank is relative to the Radius of the projectile the DamageAmount is always 20 ?

I thought that the farther the tank is from the projectile when it hit , the less Damage amount it take.
So i guess this mechanism is actif when we use super::TakeDamage ( i haven’t tied that yet).

And if DamageAmount is always 20, why do we use RoundsToInt instead of a simple ToInt ?

You might want to look into the “Apply Radial Damage with Falloff” function :slight_smile:

Privacy & Terms