RealDocs

AActor::GetInstigatorController

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

Description

Returns the controller of this actor's instigator pawn, or nullptr if there is no instigator or the instigator has no controller. Convenient shorthand for GetInstigator()->GetController().

Caveats & Gotchas

  • Returns nullptr if the instigator pawn exists but has been possessed by a different controller or has died and lost its controller — always null-check the result.
  • A templated overload (GetInstigatorController<T>()) allows you to retrieve and cast to a specific controller subclass (e.g. APlayerController) in a single call.

Signature

ENGINE_API AController* GetInstigatorController() const

Return Type

AController*

Example

Award points to the player who fired a projectile C++
void AMyProjectile::OnHit(AActor* HitActor)
{
    if (APlayerController* PC = GetInstigatorController<APlayerController>())
    {
        PC->AddScore(10);
    }
}

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.