In the course we use this from UGameplayStatics:
UGameplayStatics::ApplyDamage(
OtherActor, // Actor that will be damaged.
Damage, // Damage amount.
InstigatorController, // Which player instigated it.
this, // What actor caused the damage.
DamageType // Type of damage done.
);
but I stumbled on “TakeDamage()” when seeing if there was anything specific to OtherActor.
FDamageEvent DamageEvent;
OtherActor->TakeDamage(
Damage, // Damage amount.
OUT DamageEvent, // Data package to describe the damage.
InstigatorController, // Which player instigated it.
this // What actor caused the damage.
);
I see the main difference (I think) is ApplyDamage() allows you to specify the DamageType, whereas the AActor’s TakeDamage() provides you with a DamageEvent type that seems to contain or let you set the DamageType along with other info.
In game development, are there examples of why use one over the other?
Would we be able to use TakeDamage() over ApplyDamage() in our project’s case, or does it matter?