AActor::TakeDamage
#include "GameFramework/Actor.h"
Access: public
Specifiers: virtual
Description
Entry point for applying damage to this actor. Override this in subclasses to implement health deduction, armor, shields, or any damage response logic.
Caveats & Gotchas
- • The base implementation simply fires the AnyDamage Blueprint event. It does *not* track health — you must implement that yourself.
- • Do not call damage logic directly; prefer UGameplayStatics::ApplyDamage or UGameplayStatics::ApplyPointDamage which route through TakeDamage and handle the EventInstigator correctly.
- • The return value is the actual damage applied after modifiers — callers can use this to credit kills, etc.
Signature
virtual float TakeDamage(float DamageAmount, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, AActor* DamageCauser) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| DamageAmount | float | The raw damage amount before any modifiers. | — |
| DamageEvent | struct FDamageEvent const& | Data package describing the type and properties of the damage. | — |
| EventInstigator | class AController* | The controller responsible for the damage (e.g. the shooter). | — |
| DamageCauser | AActor* | The actor that directly caused the damage (e.g. the projectile). | — |
Return Type
float Example
Basic health deduction override C++
float AMyCharacter::TakeDamage(float DamageAmount, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser)
{
float ActualDamage = Super::TakeDamage(DamageAmount, DamageEvent, EventInstigator, DamageCauser);
Health = FMath::Max(0.f, Health - ActualDamage);
if (Health <= 0.f)
{
Die();
}
return ActualDamage;
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?