ApplyDamage - how does it work?

I’m curious about BaseDamage variable. It apply damage to… what exactly ?

Assuming I have Character with property called “SuppperrrrHealth”, how do I tell ApplyDamage to actually apply damage to this property ?

Should I override this function, or this is something defined by DamageType, and it will tell this function what should it do ?

If so, how would I tell DamgeType, which property it should use to apply damage ?

Hi Lukasz,

When an actor has its TakeDamage() called, you can several options how to respond to it. Essentially though, you need to find a good place to do

SuppperrrrHealth -= Damage;

and any related damage handling code (e.g. damage effects, death handling, etc).

Some options:

  • In C++, overload TakeDamage() and handle it there
  • In C++, bind a delegate to OnTakeAnyDamage (or one of the related hooks) and handle it in your delegate
  • In Blueprints,add a ReceivedAnyDamage (or one of the related events) and handle it in the event graph
  • In a Level Blueprint, add a OnTakeAnyDamage event and handle it there

Hope that helps!

Thanks for answer!

But I was actually curious about Blueprint function

Defined in GameplayStatics.h

ApplyDamage() is basically a global, Blueprint-friendly way to invoke AActor::TakeDamage() on the damaged actor. So if you want to cause damage on something, ApplyDamage is an appropriate way to do that. If you want to respond to damage (caused by ApplyDamage or any other method), the techniques above are the way to go. :slight_smile: