Hello all,
I am currently implementing UE’s damage system. Events wasn’t getting called both in C++ and BP. So I had to debug and I see what was wrong and it was BaseDamage != 0.f check in UGameplayStatics::Apply%insertAnyKindOfDamageHere%Damage function:
if(DamagedActor && BaseDamage != 0.f)
Why would someone want to add "!= 0.f " to flow ? Is there any logical explanation ? It’s perfectly understandable to not do “zero” damage but either why it is not permitted ?
Thanks,
That means if the amount of (damage == 0.0f) then there’s no point to calculate the actual damage and that means no damage taken. But why? Let’s take an example of a game where a character is in “Invincible” state, so when the character is in “invincible” state we set the damage to 0.0f.
I usually override the TakeDamage function in my actor so the code will be similar like this:
in AMyActor.h
virtual float TakeDamage (float DamageAmount, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, AActor * DamageCauser) override;
in AMyActor.cpp
float TakeDamage (float DamageAmount, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, AActor * DamageCauser)
{
if (bIsInvincible)
{
DamageAmount = 0.0f;
}
return Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
}
I hope this is answer your question
Well,
I still think that it should be controlled by a boolean such as bSkipEventIfZeroDamage.