Description
Returns whether this actor can receive damage. The default `TakeDamage` implementations check this flag and return 0 when it is false.
Caveats & Gotchas
- • This only gates the default `TakeDamage` path. If you have a custom damage system that bypasses `TakeDamage`, this flag will not be consulted and you must check it manually.
- • The flag is stored in the private `bCanBeDamaged` bitfield. It defaults to true in `AActor`. Actors that should never be damaged (props, cameras) should set it to false in their constructor.
Signature
bool CanBeDamaged() const Return Type
bool Example
Guard a damage application C++
void AMyDamageSystem::ApplyDamage(AActor* Target, float Amount)
{
if (Target && Target->CanBeDamaged())
{
Target->TakeDamage(Amount, FDamageEvent(), nullptr, nullptr);
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?