RealDocs

AActor::GetInstigator

function Engine Blueprint Since 4.0
#include "GameFramework/Actor.h"
Access: public Specifiers: UFUNCTIONBlueprintCallableconst

Description

Returns the pawn responsible for spawning or triggering this actor, or nullptr if none was set. The instigator is used by the damage system to attribute damage and determine friendly fire.

Caveats & Gotchas

  • The instigator is set at spawn time via FActorSpawnParameters::Instigator and is not automatically replicated — on clients it may be null unless you replicate it yourself or use GetInstigatorController() after the instigator has been replicated.
  • A templated overload (GetInstigator<T>()) exists for casting in one call. It returns nullptr if the instigator is not of the requested type.

Signature

ENGINE_API APawn* GetInstigator() const

Return Type

APawn*

Example

Get instigator in TakeDamage to avoid friendly fire C++
float AMyActor::TakeDamage(float DamageAmount, FDamageEvent const& DamageEvent,
    AController* EventInstigator, AActor* DamageCauser)
{
    APawn* Instigator = DamageCauser ? DamageCauser->GetInstigator() : nullptr;
    if (Instigator && Instigator->GetTeamIndex() == GetTeamIndex())
    {
        return 0.f; // Friendly fire ignored
    }
    return Super::TakeDamage(DamageAmount, 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.