RealDocs

APawn::ShouldTakeDamage

function Engine Since 4.0
#include "GameFramework/Pawn.h"
Access: public Specifiers: virtualconst

Description

Called at the start of TakeDamage to decide whether damage processing should proceed. Returns false to completely ignore incoming damage without applying any effects.

Caveats & Gotchas

  • The base APawn implementation checks bCanBeDamaged and also returns false on clients in networked games (damage is authoritative server-side). Override carefully or authority checks will be skipped.
  • If you override TakeDamage without calling Super and apply your own logic, this function will never be reached — make sure to call Super::ShouldTakeDamage() or replicate the checks yourself.

Signature

virtual bool ShouldTakeDamage(float Damage, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) const;

Parameters

Name Type Description Default
Damage float The amount of damage being applied.
DamageEvent FDamageEvent const& The damage event describing type and hit info.
EventInstigator AController* The controller responsible for the damage.
DamageCauser AActor* The actor that directly caused the damage (e.g., a projectile).

Return Type

bool

Example

Ignore damage of a specific type C++
bool AMyPawn::ShouldTakeDamage(float Damage, FDamageEvent const& DamageEvent, AController* EventInstigator, AActor* DamageCauser) const
{
	if (DamageEvent.DamageTypeClass && DamageEvent.DamageTypeClass->IsChildOf(UFireDamageType::StaticClass()))
	{
		return false; // Immune to fire
	}
	return Super::ShouldTakeDamage(Damage, DamageEvent, EventInstigator, DamageCauser);
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.