RealDocs

APawn::LastHitBy

property Engine Blueprint Since 4.0
#include "GameFramework/Pawn.h"
Access: public Specifiers: UPROPERTYBlueprintReadOnly

Description

The controller of the last actor that dealt damage to this pawn. Updated automatically by TakeDamage and used as a fallback instigator when resolving damage attribution (e.g., for kill credit).

Caveats & Gotchas

  • This is a transient, non-replicated property — its value is only valid on the machine where damage was processed (typically the server). Client-side reads will usually return nullptr.
  • Only updated by APawn::TakeDamage when the damage instigator is non-null. Self-inflicted damage or world damage with no EventInstigator will not overwrite LastHitBy.
  • The pointer is a weak-like TObjectPtr — the controller may become invalid (e.g., player disconnected) between the damage event and when you read the property. Always guard with IsValid().

Signature

TObjectPtr<AController> LastHitBy

Example

Award kill credit using LastHitBy C++
void AMyPawn::OnDeath()
{
	// LastHitBy is the attacker's controller — award score
	if (IsValid(LastHitBy))
	{
		if (AMyPlayerState* PS = LastHitBy->GetPlayerState<AMyPlayerState>())
		{
			PS->AddKill();
		}
	}
}

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.