RealDocs

UAbilitySystemComponent::OnPlayerControllerSet

function GameplayAbilities Since 4.20
#include "AbilitySystemComponent.h"
Access: public Specifiers: virtual

Description

Called when the ASC's AbilityActorInfo has a PlayerController assigned. Override this in subclasses to react to the moment local player input becomes available.

Caveats & Gotchas

  • The base implementation is a no-op empty body — you must override it in a subclass to gain any functionality. Calling Super::OnPlayerControllerSet() is harmless but not required.
  • This fires as part of InitAbilityActorInfo / SetAvatarActor flow, and only when the PlayerController is non-null. It is NOT called when the controller is cleared.
  • In split-screen or listen-server scenarios, this can fire on the server for AI-controlled pawns that gain a controller; verify IsLocalController() inside the override if you only want local logic.

Signature

virtual void OnPlayerControllerSet() { }

Return Type

void

Example

Bind local input after controller is known C++
void UMyAbilitySystemComponent::OnPlayerControllerSet()
{
    Super::OnPlayerControllerSet();
    // Safe to bind input here — we know the PC exists
    if (APlayerController* PC = AbilityActorInfo->PlayerController.Get())
    {
        BindAbilityInputs(PC);
    }
}

Version History

Introduced in: 4.20

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.